Skip to content

Requests

Cassiopeia provides a very simple RESTful API to generate PDFs. The API is designed to be easy to use and integrate into your system. The examples in this documentation use curl for simplicity.

Generating a PDF

The endpoint we use is POST /api/documents which takes documents either via multipart/form-data or via JSON field with base64 encoded files.

Via inline base64

In this example we send a POST request to the /api/documents endpoint with a base64 encoded file. The file is sent as a JSON object with a templates field containing an array of base64 encoded files. The base64 command is used to encode the file.

Sending multiple files is also possible by adding more base64 encoded files to the templates array.

json
{
  "templates": ["..."]
}

The curl command looks like this:

bash
curl -X POST "https://www.cassiopeia-api.cloud/api/documents" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d "{\"templates\": [\"$(base64 -w 0 -i /path/to/your/file )\"]}"

The response will be a JSON object with the base64 encoded PDF:

json
{
  "data": {
    "pdf": "..."
  }
}

See the responses chapter for details.

Via Multipart/Form-Data

In this example we use curl to send a POST request to the /api/documents endpoint with a file sent as multipart/form-data. The file is sent as a file field with the name files. Sending multiple files is also possible by adding more file fields.

bash
curl -X POST "https://www.cassiopeia-api.cloud/api/documents" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -F "files[]=@./path/to/your/file"

The result will be a JSON object with the base64 encoded PDF:

json
{
  "data": {
    "pdf": "..."
  }
}

See the responses chapter for details.

It's also possible to pass JSON content as a text part for example to pass variables or other options.

Limits

Currently the request size is limited to 10MB. If you need to send larger files, please contact us.