Skip to main content
POST
/
writer
/
writers
/
{writerId}
/
works
/
{workId}
Associate a writer with a work
curl --request POST \
  --url https://api.royalti.io/writer/writers/{writerId}/works/{workId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "writerRole": "CA",
  "capacity": "SW",
  "territories": [
    {
      "territoryCode": "WW",
      "inclusionExclusion": "I",
      "prShare": 100,
      "mrShare": 100,
      "srShare": 100
    }
  ]
}
'
import requests

url = "https://api.royalti.io/writer/writers/{writerId}/works/{workId}"

payload = {
"writerRole": "CA",
"capacity": "SW",
"territories": [
{
"territoryCode": "WW",
"inclusionExclusion": "I",
"prShare": 100,
"mrShare": 100,
"srShare": 100
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
writerRole: 'CA',
capacity: 'SW',
territories: [
{
territoryCode: 'WW',
inclusionExclusion: 'I',
prShare: 100,
mrShare: 100,
srShare: 100
}
]
})
};

fetch('https://api.royalti.io/writer/writers/{writerId}/works/{workId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.royalti.io/writer/writers/{writerId}/works/{workId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'writerRole' => 'CA',
'capacity' => 'SW',
'territories' => [
[
'territoryCode' => 'WW',
'inclusionExclusion' => 'I',
'prShare' => 100,
'mrShare' => 100,
'srShare' => 100
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.royalti.io/writer/writers/{writerId}/works/{workId}"

payload := strings.NewReader("{\n \"writerRole\": \"CA\",\n \"capacity\": \"SW\",\n \"territories\": [\n {\n \"territoryCode\": \"WW\",\n \"inclusionExclusion\": \"I\",\n \"prShare\": 100,\n \"mrShare\": 100,\n \"srShare\": 100\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.royalti.io/writer/writers/{writerId}/works/{workId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"writerRole\": \"CA\",\n \"capacity\": \"SW\",\n \"territories\": [\n {\n \"territoryCode\": \"WW\",\n \"inclusionExclusion\": \"I\",\n \"prShare\": 100,\n \"mrShare\": 100,\n \"srShare\": 100\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.royalti.io/writer/writers/{writerId}/works/{workId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"writerRole\": \"CA\",\n \"capacity\": \"SW\",\n \"territories\": [\n {\n \"territoryCode\": \"WW\",\n \"inclusionExclusion\": \"I\",\n \"prShare\": 100,\n \"mrShare\": 100,\n \"srShare\": 100\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "workId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "writerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "territories": [
    {
      "territoryCode": "WW",
      "prShare": 50,
      "mrShare": 50,
      "srShare": 50,
      "startDate": "2023-11-07T05:31:56Z",
      "endDate": "2023-11-07T05:31:56Z"
    }
  ],
  "sourceLineNumber": 123,
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "shareTotals": {},
  "writer": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "tenantId": 123,
    "firstName": "<string>",
    "lastName": "<string>",
    "ipiNameNumber": "<string>",
    "ipiBaseNumber": "<string>",
    "affiliatedPRO": "<string>",
    "mrSociety": "<string>",
    "srSociety": "<string>",
    "generallyControlled": false,
    "canBeControlled": false,
    "publisherFee": 50,
    "saan": "<string>",
    "territories": [
      {
        "territoryCode": "WW",
        "prShare": 50,
        "mrShare": 50,
        "srShare": 50,
        "startDate": "2023-11-07T05:31:56Z",
        "endDate": "2023-11-07T05:31:56Z"
      }
    ],
    "settings": {},
    "tenantUserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "userData": {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "firstName": "<string>",
      "lastName": "<string>",
      "email": "jsmith@example.com",
      "ipi": "<string>"
    },
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z"
  }
}
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"writerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"territories": [
{
"territoryCode": "WW",
"prShare": 50,
"mrShare": 50,
"srShare": 50,
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z"
}
],
"sourceLineNumber": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"shareTotals": {},
"writer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenantId": 123,
"firstName": "<string>",
"lastName": "<string>",
"ipiNameNumber": "<string>",
"ipiBaseNumber": "<string>",
"affiliatedPRO": "<string>",
"mrSociety": "<string>",
"srSociety": "<string>",
"generallyControlled": false,
"canBeControlled": false,
"publisherFee": 50,
"saan": "<string>",
"territories": [
{
"territoryCode": "WW",
"prShare": 50,
"mrShare": 50,
"srShare": 50,
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z"
}
],
"settings": {},
"tenantUserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userData": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"firstName": "<string>",
"lastName": "<string>",
"email": "jsmith@example.com",
"ipi": "<string>"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}
{
"status": "error",
"message": "<string>",
"code": "<string>",
"details": {}
}
{
"status": "error",
"message": "<string>",
"code": "<string>",
"details": {}
}
This endpoint requires authentication. Include your Bearer token in the Authorization header.

Description

POST /writer/writers//works/ Description: Creates (or, if one already exists for this writer/work/role, updates) a CWRWorkWriter association. Validates each territory entry’s code, I/E flag, and PR/MR/SR share ranges; validates writerRole against the narrower work-association enum (CA/AR/AD/TR, default CA), capacity (SW/OW/AC, default SW), and sourceType (AGR/CWR/REG) if supplied. Response includes shareTotals — summed PR/MR/SR shares per territory code across ALL writers currently on the work. Returns 201 when a new association was created, 200 when an existing one (same writerId/workId/writerRole) was updated. Authorization:
  • Required role: admin or higher
Method: POST

Code Examples

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

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

response = requests.post(
  'https://api.royalti.io/writer/writers/example-id/works/example-id',
  headers={
    'Authorization': f'Bearer {token}'
  },
  json={"ref":"#/components/schemas/WorkAssignmentRequest"}
)

data = response.json()
print(data)
curl -X POST https://api.royalti.io/writer/writers/example-id/works/example-id \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ref":"#/components/schemas/WorkAssignmentRequest"}'

Authorizations

Authorization
string
header
required

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

Path Parameters

writerId
string<uuid>
required
workId
string<uuid>
required

Body

application/json
writerRole
enum<string>
default:CA

Note this is a narrower enum than the writer's own writerRole field — only these 4 codes are valid for a work association.

Available options:
CA,
AR,
AD,
TR
territories
object[]

Each entry is validated (territory code, I/E, and PR/MR/SR share ranges); invalid entries fail the whole request with 400.

capacity
enum<string>
default:SW
Available options:
SW,
OW,
AC
sourceType
enum<string>
Available options:
AGR,
CWR,
REG
sourceLineNumber
integer

Response

Existing association updated

Association record linking a writer to a work, with per-writer territory/share overrides.

id
string<uuid>
workId
string<uuid>
writerId
string<uuid>
writerRole
enum<string>
Available options:
CA,
AR,
AD,
TR
territories
object[]
capacity
enum<string>
Available options:
SW,
OW,
AC
sourceType
enum<string> | null
Available options:
AGR,
CWR,
REG
sourceLineNumber
integer | null
createdAt
string<date-time>
updatedAt
string<date-time>
shareTotals
object

Sum of PR/MR/SR shares across all writers on the work, keyed by territory code.

writer
object