Skip to main content

Build request reference

The build request is the same in the three languages:

  • Rust: ddex_builder::BuildRequest and the *Request structs in ddex_builder::builder. Every struct implements Default, so you can write ..Default::default() for the fields you leave out.
  • Node.js: a plain object, typed as BuildRequest in build-request.d.ts.
  • Python: a dict, typed as ddex_builder.BuildRequest (a TypedDict in ddex_builder.build_request). It is converted through JSON, so only JSON values are allowed.

Field names are the same snake_case names everywhere. In Node.js and Python an optional field can be omitted or set to null / None. Fields marked Required below must be present for the request to be read at all; which values each ERN version needs on top of that is listed under required fields by ERN version.

Nothing is filled in from defaults: a value the target ERN version requires but the request does not carry fails the build (errors). The only values the builder generates are the message ID, the creation time and the release and resource references, when they are left out (canonical output).

BuildRequest​

FieldTypeDescription
headerMessageHeaderRequired.
versionstringRequired, no default: "4.3", "4.2", "3.8.2" or "3.8.1". Anything else fails (unsupported ERN version '4.1'; the builder can target 3.8.1, 3.8.2, 4.2 or 4.3)
releasesRelease[]The releases. ERN 4.x: exactly one per message; 3.8.x: at least one
dealsDeal[]The deals
language_and_script_codestringNewReleaseMessage/@LanguageAndScriptCode, e.g. en. Required by ERN 4.x
avs_version_idstringNewReleaseMessage/@AvsVersionId, e.g. 12. Required by ERN 4.3
profilestringA profile name. It does not change the output in 0.5.0
extensionsmap of string to stringNot written in 0.5.0

MessageHeader​

FieldTypeDescription
message_senderPartyRequired.
message_recipientPartyRequired.
message_idstringMessageId. Generated (a UUID) when omitted
message_control_typestringLiveMessage or TestMessage
message_created_date_timestringMessageCreatedDateTime, an xs:dateTime such as 2024-01-01T00:00:00Z. The current time when omitted

Party​

FieldTypeDescription
party_nameLocalizedString[]Required (the list; may be empty). The name; the header allows one
party_idstringPartyId. Required for the sender and the recipient. ERN 4.x: a DDEX Party ID matching PADPIDA[a-zA-Z0-9]+
party_referencestringA party reference

LocalizedString​

FieldTypeDescription
textstringRequired. The text
language_codestringIts LanguageAndScriptCode

AvsValue​

Fields typed AvsValue take a DDEX allowed-value-set term as a string ("Album"), or an object for a user-defined value:

FieldTypeDescription
valuestringRequired. The term, e.g. UserDefined
user_defined_valuestring@UserDefinedValue
namespacestring@Namespace, the party that defined the value

In Rust the type is AvsValueRequest, which converts from &str and String ("Album".into()).

Release​

FieldTypeDescription
release_idstringRequired (may be ""). Written as ReleaseId/GRid unless release_ids is set
upcstringWritten as ReleaseId/ICPN unless release_ids is set
release_idsReleaseIdsAll the release's identifiers; replaces release_id and upc
release_referencestringReleaseReference, matching R[\d\-_a-zA-Z]+. Generated when omitted
titleLocalizedString[]Required (the list). 4.x DisplayTitleText, 3.8.x ReferenceTitle
artiststringRequired. The display artist (4.x: DisplayArtistName and a MainArtist DisplayArtist)
artist_roleAvsValueThe display artist's role (default MainArtist)
labelstringThe label name. ERN 4.x writes it as a party referenced by ReleaseLabelReference
release_typeAvsValueReleaseType, e.g. Album, Single
genre, sub_genrestringGenre/GenreText, Genre/SubGenre
parental_warning_typestringParentalWarningType, e.g. NotExplicit
release_datestringAn ISO date YYYY, YYYY-MM or YYYY-MM-DD
tracksTrack[]Required (the list). The release's sound recordings and videos
resource_referencesstring[]The tracks the release lists, when it is not all of them
resource_groupResourceGroupAn explicit ResourceGroup tree (ERN 4.x). Use either this or the tracks' disc_number / sequence_number

ReleaseIds​

FieldTypeDescription
gridstringGRid
icpnstringICPN (UPC/EAN)
proprietary_ids{ namespace, value }[]ProprietaryIds; namespace is required

ResourceGroup​

FieldTypeDescription
resource_group_typestring@ResourceGroupType, e.g. Component; required on nested groups
sequence_numberintegerSequenceNumber
resource_groupsResourceGroup[]Nested groups
content_items{ resource_reference, sequence_number }[]The tracks in this group, by resource reference

Track​

FieldTypeDescription
track_idstringRequired. An ID for the track within the request
resource_referencestringResourceReference, matching A[\d\-_a-zA-Z]+. Generated when omitted
isrcstringRequired (may be "" when proprietary_ids is given). The resource's ISRC
proprietary_ids{ namespace, value }[]The resource's ProprietaryIds
titlestringRequired. 4.x DisplayTitleText, 3.8.x ReferenceTitle
durationstringRequired. An xs:duration such as PT3M42S
artiststringRequired. The display artist
artist_roleAvsValueThe display artist's role (default MainArtist)
resource_kind"SoundRecording" or "Video"Default SoundRecording. Videos are written for ERN 4.x only
resource_typeAvsValueThe resource's DDEX Type, e.g. MusicalWorkSoundRecording
parental_warning_typestringParentalWarningType
disc_numberintegerPlaces the track on a disc (a Component group)
sequence_numberintegerThe track's SequenceNumber
track_releaseTrackReleaseERN 4.x: a TrackRelease for this track

TrackRelease​

FieldTypeDescription
release_referencestringRequired. Its ReleaseReference (deals can reference it)
release_idsReleaseIdsRequired (with at least one identifier)
titlestringIts title
labelstringIts label (required by ERN 4.x)
genre, sub_genrestringIts genre (genre required by ERN 4.x)

Deal​

FieldTypeDescription
release_referencesstring[]Required. The release or track release references the deal applies to; each must be in the message
deal_termsDealTermsRequired.
deal_referencestringDealReference

DealTerms​

FieldTypeDescription
commercial_model_typestringRequired (may be ""; ERN 4.x omits it when empty), e.g. SubscriptionModel
territory_codestring[]Required (the list). TerritoryCodes, e.g. Worldwide
start_date, end_datestringValidityPeriod dates, YYYY-MM-DD
use_typesstring[]UseTypes, e.g. Stream

Required fields by ERN version​

The builder checks what the target version's schema requires before it writes anything:

Request fieldERN 4.3ERN 4.2ERN 3.8.2 / 3.8.1
language_and_script_code✓✓
avs_version_id✓
header.message_sender.party_id, header.message_recipient.party_id✓ (DPID)✓ (DPID)✓
exactly one release✓✓at least one
a release identifier (release_id, upc or release_ids)✓✓✓
release title✓✓✓ (or the first track's title)
release artist✓✓
release label✓✓
release release_type✓✓
release genre✓✓
release parental_warning_type✓✓
at least one track (or resource_references)✓
track isrc or proprietary_ids✓✓✓
track title✓✓✓
track duration✓✓✓
track artist✓✓
track resource_type✓✓
track parental_warning_type✓✓
track_release.release_ids, .label, .genre✓✓release_ids
deal release_references✓✓✓
deal start_date✓✓start_date or end_date
deal territory_code, use_types✓

Values that are given are also checked against the schema's patterns: references (R..., A...), DPIDs, dates, xs:dateTime, xs:duration, that a deal references a release in the message, and that each track is placed exactly once when resource_group is used. ERN 3.8.x targets reject video tracks.

Errors​

Every problem is collected before the build fails, so one error lists all of them. Each entry has one of two forms:

ERN 4.3 requires Release/ReleaseType (releases[0].release_type)
ERN 4.2: releases[0].tracks[0].duration is "3 minutes"; the schema requires an xs:duration such as PT3M45S

The first names the schema element and the request field that is missing; the second names the request field whose value does not fit the schema, and why.

LanguageWhat you get
RustErr(BuildError::ValidationFailed { errors }), one String per entry. Its Display is Validation failed: followed by the entries joined with ,
Node.jsThe promise rejects with an Error whose message is Build failed: Validation failed: .... An object that is not a build request at all (a missing header or party_name, a wrong type) rejects with Invalid build request: ...
PythonRuntimeError("Build failed: Validation failed: ..."). A dict that is not a build request at all (a missing header, a wrong type) raises ValueError("Invalid build request: ...")

The building quick start shows each case in code.

Escaping and illegal characters​

Text is written exactly as given and XML-escaped:

  • In text: &, < and > are escaped, and a carriage return is written as &#13; (a parser would otherwise turn it into a line feed).
  • In attribute values: also " and ', and tab, line feed and carriage return as character references (attribute-value normalization would otherwise turn them into spaces).

So the output always parses back to the input text. Metadata that looks like SQL, HTML or script is not rejected; it is escaped like any other text.

Characters that XML 1.0 does not allow anywhere (the C0 control characters other than tab, line feed and carriage return, and U+FFFE and U+FFFF) cannot be escaped, so the build fails up front, naming the field and the character:

Build failed: Invalid format in releases[0].title[0].text: contains U+0001, which XML 1.0 does not allow (control characters other than tab, LF and CR, U+FFFE and U+FFFF); remove it from the input
const assert = require('node:assert/strict');
const { DdexBuilder } = require('ddex-builder');
const { DdexParser } = require('ddex-parser');

const party = (name, id) => ({ party_name: [{ text: name }], party_id: id });
const request = (title) => ({
header: {
message_sender: party('Example Label', 'PADPIDA0000000001'),
message_recipient: party('Example DSP', 'PADPIDA0000000002'),
},
version: '4.3',
avs_version_id: '12',
language_and_script_code: 'en',
releases: [{
release_id: 'A1-ABCDE-0000000001-M',
title: [{ text: title }],
artist: 'Example Artist',
label: 'Example Label',
release_type: 'Single',
genre: 'Pop',
parental_warning_type: 'NotExplicit',
tracks: [{
track_id: 'T1',
isrc: 'ZZ0000000001',
title: 'Example Track',
duration: 'PT3M42S',
artist: 'Example Artist',
resource_type: 'MusicalWorkSoundRecording',
parental_warning_type: 'NotExplicit',
}],
}],
});

async function main() {
// Escaped on output, read back unchanged
const xml = await new DdexBuilder().build(request('Rock & Roll <Live>'));
assert.ok(xml.includes('Rock &amp; Roll &lt;Live&gt;'));
assert.equal(new DdexParser().parseSync(xml).releases[0].title, 'Rock & Roll <Live>');

// A character XML 1.0 does not allow is rejected
await assert.rejects(
new DdexBuilder().build(request('Bad\u0001Title')),
/releases\[0\]\.title\[0\]\.text: contains U\+0001/,
);
}

main();

Canonical output​

Output is canonicalized with DB-C14N/1.0 (the project's specification): fixed namespace prefixes, sorted attributes, consistent indentation, and elements in XSD order.

It is not byte-for-byte deterministic yet: with the default options, a message ID, release and resource references and MessageCreatedDateTime that the request leaves out are generated (random UUIDs, the current time), and the Rust stable-hash ID option puts the current date into the MessageId. Give message_id, message_created_date_time, release_reference and each track's resource_reference, and nothing is generated. Full determinism (stable IDs by default) is planned for 0.6.0.

The builder does not validate its output against the XSD or the AVS rules at runtime; the required-field checks above are what it enforces. CI validates the output of every supported version except 3.8.1 against the official XSDs (ERN version support).