Skip to main content

Create audience

POST/api/audiences
Administrator

Read more: Retiring an audienceSource: AudienceApiController#create(opens in new tab)

Request body​

application/json

FieldTypeRequiredNotes
displayNamestringRequiredmax 120
communicationIntentstringOptionalmax 1000
templateBodystringOptional
footerTemplateBodystringOptional
codestringRequiredmax 64 · pattern [a-z][a-z0-9_]*

Response​

Success: 201

FieldTypeRequiredNotes
idstring (uuid)Optional
codestringOptional
displayNamestringOptional
communicationIntentstringOptional
templateBodystringOptional
footerTemplateBodystringOptional
presetbooleanOptional
createdAtstring (date-time)Optional
updatedAtstring (date-time)Optional
templateVariantsmap of stringOptional
footerTemplateVariantsmap of stringOptional
retiredAtstring (date-time)Optional
retirerNamestringOptional

Errors​

StatusCodeApplies to
400validation_faileda field is missing or out of rangeAny endpoint
400malformed_requestthe body cannot be readAny endpoint
400invalid_parametera path or query parameter is missing or does not convert, such as an ID that is not a UUIDAny endpoint
401authentication_requiredno sessionAny endpoint
403access_deniedan administrator endpoint, or a missing or stale CSRF tokenAny endpoint
404not_foundno such addressAny endpoint
405method_not_allowedthe address does not take that methodAny endpoint
415unsupported_media_typethe address does not read a body of that typeAny endpoint
500internal_errora fault ReleaseFlow did not foresee; the body never carries the exception behind itAny endpoint
400template_invalidAudiences area
400template_narratives_pathAudiences area
400template_language_not_targetedAudiences area
400invalid_release_languagesAudiences area
404audience_not_foundAudiences area
409audience_code_takenAudiences area
409audience_limitAudiences area
409audience_lastAudiences area
409audience_last_activeAudiences area
409audience_already_retiredAudiences area
409audience_not_retiredAudiences area
409audience_in_useAudiences area
409audience_not_presetAudiences area
404glossary_term_not_foundGlossary area
409glossary_term_takenGlossary area
409glossary_limitGlossary area
400invalid_release_scheduleReleases area
400invalid_upgrade_guide_urlReleases area
400invalid_previous_releaseReleases area
400invalid_fold_decisionReleases area
404release_not_foundReleases area
404release_note_not_foundReleases area
404folding_suggestion_not_foundReleases area
404linked_issue_not_foundReleases area
409release_status_conflictReleases area
409release_publishedReleases area
409release_emptyReleases area
409release_review_incompleteReleases area
409change_summary_requiredReleases area
409release_version_takenReleases area
409classification_changedReleases area
409change_not_releasableReleases area
409change_excludedReleases area
409release_note_render_failedReleases area
409release_notes_missingReleases area
409translations_not_readyReleases area
409linked_issue_status_changedReleases area

Request

bash
# Sign in first and keep the session cookie in cookies.txt (see Sessions and CSRF).
# CSRF_HEADER and CSRF_TOKEN are the headerName and token GET /api/csrf returned.
curl -X POST "http://localhost:8080/api/audiences" \
-b cookies.txt -c cookies.txt \
-H "$CSRF_HEADER: $CSRF_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"displayName": "<string>",
"communicationIntent": "<string>",
"templateBody": "<string>",
"footerTemplateBody": "<string>",
"code": "<string>"
}'

The request body is an example built from the schema; replace every placeholder.

Response

201

Example

{
  "id": "<uuid>",
  "code": "<string>",
  "displayName": "<string>",
  "communicationIntent": "<string>",
  "templateBody": "<string>",
  "footerTemplateBody": "<string>",
  "preset": false,
  "createdAt": "<date-time>",
  "updatedAt": "<date-time>",
  "templateVariants": {
    "<key>": "<string>"
  },
  "footerTemplateVariants": {
    "<key>": "<string>"
  },
  "retiredAt": "<date-time>",
  "retirerName": "<string>"
}