Schema Validation
How to validate CWR-JSON files using the published JSON Schema and lookup tables.
Published assets (format 1.0.1)
| Asset | File | Notes |
|---|---|---|
| JSON Schema | cwr-json-schema-v1.0.schema.json | Validates format 1.0.1. Written in JSON Schema language version draft-07, which Ajv 8 supports by default. The filename keeps v1.0 for every 1.0.x format (see Version governance) |
| Lookup table | cwr_lookup_data_types_v1.0_r0.json | Allowed value sets (role codes, TIS, title types, …). The file content reports "revision": "r1" (CISAC society, character set, language, revocation and anomalous-work sets added in Validation 1.1.2) |
The schema embeds lookup enums and field patterns derived from the lookup table, so you only need the schema file to validate. CISAC CWR 2.x lookup tables (CWR08-3615R2, 2026-03-31) are the source for most enum sets; TIS codes come from the CISAC TIS export.
Lookup data types
| Set | Used on |
|---|---|
roleCodes | parties[].role |
rightsTypes | shares[].rightsType |
shareTypes | shareTypes[].type (own, coll) |
controlled | parties[].controlled |
titleTypes | titles[].type |
identifierSources | Not used by format 1.0.1 validation. Kept in the lookup file for older tooling. Format 1.0.1 validates identifiers[].type and identifiers[].source.type with closed enums in the schema (see below) |
messageTypes | messages.type |
aiUsageIndicators | flags.aiUsage |
characterSets | header.characterSet |
societyCodes | shares[].society |
languageCodes | titles[].language |
revocationReasons | messages.revocation.reason |
anomalousWorkReasons | flags.anomalousReason |
tisNumericCodes | territory include / exclude, relinquishment scope |
aiUsageIndicators contains the CISAC values M, T, A plus B, N, U, Y. Senders should use only M, T or A; the extra values are under review.
header.conventions is not a lookup set. When the object is present, writerControl must be swrOnly or swrOwr, and publisherShare must be summed or perWriterChain.
Additional CISAC reference sets (instruments, work types, transaction types, etc.) are bundled in the lookup JSON for reference. Format 1.0.1 has no fields that use them, so the schema does not enforce them.
See also TIS Territory Codes.
Identifiers
works[].identifiers[] items must match exactly one of two shapes (oneOf):
ISWC entry (IswcIdentifier): one object with an iswc string array (minItems 1) and no other properties.
{ "iswc": ["T-034.524.680-1"] }Each ISWC must be dotted T-NNN.NNN.NNN-C, compact TNNNNNNNNNC, or intermediate T-NNNNNNNNN-C. Converters should write the dotted form.
Namespaced entry (WorkIdentifier): type and value are required; source is optional. No other properties are allowed.
| Field | Rule |
|---|---|
type | publisherWorkId, societyWorkId, submitterWorkId, assetId, or proprietary |
value | string |
source | object, optional. Required properties type and value; optional name |
source.type | ipiNameNumber, cisacSociety, cwrSubmitter, or dpid |
{
"type": "submitterWorkId",
"value": "SW00000000001",
"source": { "type": "cwrSubmitter", "value": "00000000001", "name": "XRF SAMPLE PUBLISHER" }
}identifiers[].source is an object. The older string form ("source": "iswc") is not valid in format 1.0.1.
ISRC and EAN are not identifier entries. They are string arrays on recordings[].isrc (pattern ^[A-Z]{2}[A-Z0-9]{3}\d{7}$) and recordings[].releases[].ean (13 digits). Recordings and releases may carry their own identifiers[] with the WorkIdentifier shape.
What to validate
Validate every complete CWR-JSON file (the full v1.0 envelope, including messages.schema and messages.schemaDescription on each work) against the published JSON Schema. For a complete check, also apply the semantic rules listed below — JSON Schema alone does not cover all business rules.
Declaring the schema version
Do not put a $schema property at the root of a CWR-JSON data file. The root object allows only header and works (additionalProperties: false), so a data file with a root $schema fails validation:
/ [EXTRA_PROPERTY]: unexpected property "$schema"
Agree the schema version out of band (for example in the API contract or file exchange agreement).
Not the same
$schema: the published schema file itself starts with"$schema": "http://json-schema.org/draft-07/schema#". That line tells validators such as AJV which version of the JSON Schema language the schema is written in. "draft-07" is the official name of that JSON Schema language version; it does not mean CWR-JSON is a draft. It is not a property of CWR-JSON data, and you do not copy it into your files.
Validating with AJV (Node.js 18+)
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
import { readFileSync } from 'fs';
const schemaUrl =
'https://d7ap24707c.execute-api.eu-west-1.amazonaws.com/staging/api/v1/schemas/cwr-json-schema-v1.0.schema.json';
const schema = await fetch(schemaUrl).then((r) => r.json());
const data = JSON.parse(readFileSync('my-file.json', 'utf8'));
const ajv = new Ajv({ allErrors: true, strict: false });
addFormats(ajv);
const validate = ajv.compile(schema);
const valid = validate(data);
if (!valid) console.error(validate.errors);
else console.log('Valid');Install with npm install ajv ajv-formats. Save the snippet as an .mjs file (top-level await). strict: false stops Ajv 8 from printing strictTypes warnings for the conditional territory rules; validation results are the same either way.
AJV-only validation does not run the semantic rules below (territory overlap, sub-publisher own, duplicate submitter work ids). Implement the semantic pass separately.
Structural vs semantic validation
JSON Schema (structural + lookups) — enforced via AJV against the published schema:
- Required fields, types, closed objects (
additionalProperties: falseon the root,header, works, identifiers, shares, recordings, releases) - Required on every work:
messages, withmessages.schemaandmessages.schemaDescription - Lookup enums: role codes, TIS codes, title types, message types, AI indicators, character sets, society codes, language codes, revocation/anomalous reasons
identifiers[]items:oneOfthe ISWC entry or the namespaced entry (see Identifiers)- Patterns: dates (
YYYYMMDD), times (HHMMSS), IPI (11 digits), ISWC, ISRC, EAN - Optional
header.conventions: bothwriterControlandpublisherSharerequired when present - Optional
tagsonheader,works[].messages, recordings, and releases:nameplusvaluestring array (minItems1). Not mapped from CWR EDI. - Share percentages
0–100 - Conditional:
ownterritories must have empty TISinclude/exclude
Semantic pass — after JSON Schema, in strict mode:
| Rule ID | Rule |
|---|---|
TIS_OVERLAP | Same code not in both include and exclude on one entry |
OWN_EMPTY_TIS | Redundant check for own + non-empty TIS |
SUBPUB_NO_OWN | SE, AM, PA must not have own |
PUB_OWN_E_ONLY | Non-E publishers must not have own |
ID_UNIQUE_SUBMITTER | Across all works[] in one file, no two works may have a works[].identifiers[] entry with type: "submitterWorkId" and the same value. Only value is compared (source is ignored). Corresponds to the CWR EDI field SubmitterWorkNumber |
TIS_UNKNOWN | Unknown TIS (when not caught by schema enum) |
Optional normalization — a receiver may apply these fixes before validating files from other senders. Strict checks on your own output should skip it:
- Recognized ISWC → dotted
T-NNN.NNN.NNN-C - Split combined
own/collterritory rows - Strip invalid
ownon sub-publishers - Strip empty and
000society codes on shares
Not covered by the schema or the semantic rules (application-level):
| Rule | Example |
|---|---|
| Share totals | PR + MR + SR consistency across parties |
Schema versioning
Which level changes, and when, is in Version governance. Those rules apply to every release after format 1.0.1.
Published file names:
cwr-json-schema-v{MAJOR}.{MINOR}.schema.json
cwr_lookup_data_types_v{MAJOR}.{MINOR}_r{N}.json
Format 1.0.1 uses cwr-json-schema-v1.0.schema.json and cwr_lookup_data_types_v1.0_r0.json.
No more than two versions should be in active circulation at any time. When a new version is released, the oldest active version is deprecated (but may remain on the server for backward compatibility).
Updated 18 days ago