Skip to main content

Getting started with ANS

ANS (Arc XP Native Specification) is essentially a blueprint in JSON format that represents your content within Arc XP. When you create content in an Arc XP application and save it, the system generates an Arc XP JSON file. You can refer to this file as an ANS object, a content object, or a content document. Each of these documents is a specific document type within ANS—primary or secondary. The structure and properties of these JSON files vary depending on the document type. 

Arc XP APIs are designed to accept JSON data that adheres to the ANS schema. These APIs then create objects that Arc XP applications can access and manipulate. Essentially, ANS serves as the language through which content is defined and managed within the Arc XP ecosystem.

To illustrate, let's consider an article, termed as a story in ANS. This story comprises of text paragraphs, an embedded image, and an author.

con_ans_properties_as_rendered_document.png

When the story is created in Composer, the author inputs the text, adds the image from Photo Center, and includes themself as the author. This process saves the story in Composer as an ANS object.

The following JSON provides a simplified view of the story in its ANS format. Some of the metadata has been excluded for readability.

{
  "_id": "GT68FH2GYMZCMDCIYWMPITIDUB5",  
  "canonical_website": "arcxpsite",
  "content_elements": [
    {
      "_id": "PY4FH2GYMZCMDCIYWMPITICVA4",
      "content": "Beginning in late July or early August of 2024,...",
      "type": "text"
    },
    {
      "_id": "LGANVKR4NFHKTFLEND7BJHEACE",
      "content": "For years, the Mount Blue Sky Scenic Byway...",
      "type": "text"
    },
    {
      "referent": {
        "id": "MUMQSJXQFRE3HAKLMTK3T3R4QU",
        "type": "image",
        "referent_properties": {
          "subtitle": "Colorado's Front Range"
        }
      },
      "type": "reference",
      "_id”: “MUMQSJXQFRE3HAKLMTK3T3R4QU"
    },
    {
      "_id": "BA3ELFFQUVC65LVVAKSS35HWXM",
      "content": "The main focus of the project...",
      "type": "text"
    }
  ],
  "credits": {
    "by": [
      {
        "referent": {
          "id": "brianpreece",
          "type": "author"
        },
        "type": "reference"
      }
    ]
  },
  "headlines": {
    "basic": "Iconic Mountain-Top Highway is About to Close for 2 Years"
  },
  "type": "story",
  "version": "0.10.10"
}

ANS types: primary versus secondary

Some ANS document types can contain other ANS documents within their properties, for example, an article that is composed of text and photos. The article is the primary ANS document, and contained within it are supporting ANS documents, one for each picture. ANS documents that can contain other full documents are called primary document types or top-level documents. The other ANS objects are secondary types or supporting types. 

The following table categorizes ANS types as primary or secondary, along with the applications and APIs responsible for generating and storing documents for these ANS types:

ANS object

ANS type

Arc XP application

Arc XP API

story

primary

Composer

Draft API, Content API

gallery

primary

Photo Center

Photo API, Content API

video

primary

Video Center

Video API, Content API

image

secondary

Photo Center

Photo API

author

secondary

Author Service

Author API

section

secondary

Site Service

Sites API

collection

secondary

WebSked

Collections API, Content API

document redirect*

secondary

--

Draft API, Content API

tag**

secondary

Global Settings

Global Settings API

distributors**

secondary

Global Settings

Global Settings API

geographic restrictions**

secondary

Global Settings

Global Settings API

* Supports a primary document but child objects are not written in the parent’s ANS. Document redirects are not the same as what is in a story’s related_content.redirect ANS field; this field stores a story’s forward redirect URL.

** When supporting a primary document, information about this kind of Arc XP object uses a unique syntax, different from the reference syntax of the others.

Each of the Arc XP applications appears as a clickable tile on your Arc XP Admin homepage, as per your organization’s agreement about which Arc XP services are provisioned. Similarly, each of the Arc XP APIs are available based on your organization’s agreement as well. 

ANS: normalized vs denormalized

The primary ANS type—a story, video, or gallery—can contain the ANS of other objects within it. The primary ANS type has two presentations: normalized and denormalized. 

Normalized ANS

Normalized ANS writes the composited objects into the JSON properties using a reference syntax shorthand. It is called reference syntax because the JSON that represents the composited object contains a key of type: reference and a key of referent with the arc id and arc type of the target object. While typically not available to view, this reference syntax is used when the systems sends the ANS through the APIs for create or update operations.

con_referent_syntax_denormalized_reference.jpg

The left side shows an Arc XP author written into the credits.by field as a reference in a parent object. On the right, the same credits.by field is denormalized when the Content API returns the parent object.

Denormalized ANS

The second presentation is denormalized, or inflated, ANS. The content retrieved from Arc XP undergoes a process where references are substituted with the complete representation of the composited objects, which results in denormalized ANS. This means that instead of just having references to other objects, the ANS of the parent object includes the full details of all associated child objects. Arc XP follows the directives within the references to locate the objects linked to the referents’ type and id values, and replaces the shorthand reference syntax with the complete ANS of the child objects, unless a particular object cannot be found. 

The primary distinction between normalized and denormalized documents is in how they represent content. A normalized document is used to process standard create and update operations and mirrors the most recently saved state of a single document by a creator. It contains only the essential properties needed to describe the content. Conversely, a denormalized document contains the complete content body as intended for consumer viewing. In the denormalized version, all child Arc XP objects are combined—also in their fully denormalized form—with the parent object to form a single document ready for use in the view layer, such as a web browser, mobile app, or RSS feed.

ANS references

References within ANS documents are positional, and consistently maintain their relative order within the document between normalized and denormalized forms. When constructing the denormalized ANS document, Arc XP replaces references with the denormalized forms of those child objects. 

Limits to denormalized references

Arc XP limits objects to 300 denormalized references. If you exceed this, the system replaces only the first 300 references with their denormalized objects during rendering, leaving the rest in their reference syntax state.

Referent updates

A referent update occurs in Arc XP when a referenced document undergoes modification. For example, a story contains a reference to an image in its content_elements ANS key. If the image’s caption is updated in Photo Center and saved, the next time the parent story’s inflated version is requested, the denormalized image in the story contains the updated caption of the child image. If that same image is used in 1000 stories or galleries, then all 1000 objects update with the same caption change. 

Arc XP employs a caching strategy that could cause these updates to take longer to show in the view layer to the consumer. To learn more, see Catching at Arc XP.

Note

Some Arc XP objects do not cause a referent update. References to Site Service sections do not update in parent objects until the parent object itself undergoes a save event.

Referent custom properties

ANS reference syntax allows for a property in the referent field called referent_properties. This property allows you to customize and overwrite the original properties of a child object when it is used in a parent, but only for that one particular use. You write this kind of customized overwrite using a referent custom property, referent.referent_properties.{property of child object to overwrite}.

In the previous example of a fully inflated parent story from Content API, the image’s caption is contained in the object.

{
  "content_elements": [
    {
      "type": "reference",
      "referent": {
        "id": "MUMQSJXQFRE3HAKLMTK3T3R4QU",
        "type": "image",
        "referent_properties": {
          "caption": "In this story, use this caption for the image instead of the default: Road closure...' etc.",
          "subtitle": "This is an overwritten subtitle field"
        }
      }
    }
  ]
}

Inside of referent_properties, you can add some native properties of the child object that you want customized for its use in the parent content. referent_properties customizations are limited to fields that represent captions, titles, descriptions, headlines, and custom user-added fields in the additional_properties key. The values written in referent_properties do not feed back and change the original information on the source material. They are exclusive to only a single use in the parent content.

The following table provides a list of ANS fields that you are likely to nest child Arc XP objects in, resulting in reference syntax when writing create or update ANS.

ANS field

ANS Object Type

Description

content_elements

story, gallery

Content elements are an ordered list of variably-typed elements, including text, images, and videos

promo_items

story, gallery

Lists of promotional content

credits

story, gallery, video, image

Authors attributed to the content

related_content

story, video

Lists of content items this object is related to

taxonomy.primary_section

taxonomy.sections

gallery, video

Holds Site Service sections

website_primary_section

website_sections

story

Holds Site Service sections

Inline entities in ANS

In some cases, you might want to include an object within another object, but storing it separately could be excessive. In those scenarios, you can use inline entities instead of references. An inline entity is like a pre-resolved reference, included identically in both normalized and denormalized documents. It acts as a second object that travels with the containing parent object, which you cannot reference or edit independently. A common example of inline entities is authors, which you store in credits.by within ANS.

Use inline entities only for authors, tags, and distributors. For example, use inline entities when you need to record an author, tag, or distributor that does not need to be available globally in Arc XP. Instead, frame its use with syntax that ties it directly to the context of the parent object, as shown in the following example.

{
  "_id": "DEFGHIJKLMNOPQRSTUVWXYZABC",
  "type": "story",
  "version": "0.10.9",
  "headlines": {
    "basic": "Man Bites Cat"
  },
  "credits": {
    "by": [
      {
        "type": "author",
        "name": "Dr. Suess"
      }
    ]
  }
}

Content elements in ANS

In ANS, the primary method of expressing content intent is through the content_elements field in story documents. Content elements are an ordered list of variably typed elements, including text, images, videos, and dividers. You can also extend and customize these elements by implementing systems, such as using the custom_embed element in Composer.

The sequence of content elements reflects the logical order of content within a story, dictating what the consuming application should see and in what order. 

{
  "content_elements": [
    {
      "_id": "PY4FH2GYMZCMDCIYWMPITICVA4",
      "content": "Beginning in late July or early August of 2024,...",
      "type": "text"
    },
    {
      "_id": "LGANVKR4NFHKTFLEND7BJHEACE",
      "content": "For years, the Mount Blue Sky Scenic Byway...",
      "type": "text"
    },
    {
      "_id": "MUMQSJXQFRE3HAKLMTK3T3R4QU",
      "type": "image"
    },
    {
      "_id": "BA3ELFFQUVC65LVVAKSS35HWXM",
      "content": "The main focus of the project...",
      "type": "text"
    }
  ]
}

Additional properties in ANS

Several ANS types include a field named additional_properties. This field is reserved for custom use and must be valid JSON, but its specific use is undefined by ANS. This is an advanced field that should be used only after fully understanding its implications.

ANS to create and update Arc XP content

For more detailed information on how to construct ANS when creating or updating an Arc XP object, refer to the following articles: