Skip to main content
POST
/
cwr
/
export
curl --request POST \
  --url https://api.royalti.io/cwr/export \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "publisherId": "8f14e45f-ceea-4d5e-8b3a-0a1b2c3d4e5f",
  "version": "2.2"
}
'
{
  "job": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "tenantId": 123,
    "configId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "filters": {},
    "progress": 100,
    "error": "<string>",
    "resultFileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z"
  },
  "excludedWorks": [
    {}
  ],
  "excludedCount": 123
}
{
"status": "error",
"message": "<string>"
}
{
"status": "error",
"message": "<string>",
"code": "<string>",
"details": {}
}
This endpoint requires authentication. Include your Bearer token in the Authorization header.

Description

POST /cwr/export Description: Loads the publisher (with PublisherTerritory rows), the tenant’s CWRWork rows (optionally filtered to workIds) with their writer links, and generates a CWR file at the requested version. Works with no writer links, NULL relative shares, or bootstrap-seeded skeletons are excluded from the file and reported back in excludedWorks — never silently dropped. On success the rendered CWR text is persisted through the File + Cloud Storage pipeline and a CWRExportJob row is created with status: completed and resultFileId set. Poll GET /cwr/status/{publisherId} for the job list and download the bytes via GET /cwr/jobs/{jobId}/download. The legacy synchronous streaming path (?stream=true) has been removed; it never produced valid work registrations or trailer counts. A request with ?stream=true returns 400. Authorization:
  • Required role: admin or higher
Method: POST

Code Examples

const response = await fetch('https://api.royalti.io/cwr/export', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "ref": "#/components/schemas/CWRExportRequest"
  })
});

const data = await response.json();
console.log(data);
import requests

response = requests.post(
  'https://api.royalti.io/cwr/export',
  headers={
    'Authorization': f'Bearer {token}'
  },
  json={"ref":"#/components/schemas/CWRExportRequest"}
)

data = response.json()
print(data)
curl -X POST https://api.royalti.io/cwr/export \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ref":"#/components/schemas/CWRExportRequest"}'

Authorizations

Authorization
string
header
required

JWT Authorization header using the Bearer scheme. Format: "Bearer {token}"

Body

application/json
publisherIds
string<uuid>[]
required

Exactly one publisher id — a CWR file carries a single sender/publisher chain. Requests with more than one id return 400.

Required array length: 1 element
version
string
default:2.1
Example:

"2.1"

Response

Export job created and completed synchronously (the async job flow renders and persists the file before responding)

job
object

CWRExportJob row. Filters, configId, and templateId are provisioned automatically on first use for a tenant.

excludedWorks
object[]

Works excluded from the export (no writer links, NULL relative shares, bootstrap-seeded skeletons). Never silently dropped — always reported.

excludedCount
integer