JSON:API Export data

Last updated on
9 March 2026

When exporting contacts via JSON:API, the response follows the standard specification but contains specific structures tailored for CRM data. Using the example of a "Person" contact type (crm_contact--person), here are the key areas to note for your export logic:

Resource Identification

  • id: This is the UUID. Always use this for syncing with external systems to ensure consistency across different Drupal environments.

  • type: In this CRM context, it follows the pattern crm_contact--[bundle].

Key Attributes

The attributes object contains the "flat" data. In a CRM export, pay close attention to:

  • full_name: Instead of a simple string, this is a multi-value object (Given, Middle, Family) allowing for more granular data mapping in your target system.

  • relationship_statistics: This is a calculated summary. In our example, it shows how many relationships this person has (e.g., parent: 3, spouse: 1). This is useful for high-level reporting without needing to fetch every individual relationship entity.

  • changed/created: Standard ISO 8601 timestamps, ideal for "delta" exports (fetching only what changed since the last sync).

Contact Methods

Contact methods are referenced with primary entity reference fields.

  • emails, telephones, addresses: These are returned as a collection of relationship pointers.

  • Primary Flag: Note the meta.primary attribute within these relationships. This tells your export script which email or address is the "main" one for this contact

{
  "jsonapi": {
    "version": "1.1",
    "meta": {
      "links": {
        "self": {
          "href": "http://jsonapi.org/format/1.1/"
        }
      }
    }
  },
  "data": [
    {
      "type": "crm_contact--person",
      "id": "fb580b11-2796-55de-a006-a05492eabf02",
      "links": {
        "self": {
          "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02?resourceVersion=id%3A4"
        },
        "working-copy": {
          "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02?resourceVersion=rel%3Aworking-copy"
        }
      },
      "attributes": {
        "drupal_internal__id": 4,
        "drupal_internal__revision_id": 4,
        "revision_timestamp": "2026-03-08T19:28:46+00:00",
        "revision_log": null,
        "name": "Marge Simpson",
        "status": true,
        "start_date": null,
        "end_date": null,
        "age": null,
        "relationship_statistics": [
          {
            "value": "household_member:a",
            "count": 1
          },
          {
            "value": "parent:a",
            "count": 3
          },
          {
            "value": "parent:b",
            "count": 2
          },
          {
            "value": "spouse",
            "count": 1
          }
        ],
        "created": "2026-03-08T19:28:46+00:00",
        "changed": "2026-03-08T19:28:46+00:00",
        "aliases": [],
        "comment": {
          "status": 2,
          "cid": 0,
          "last_comment_timestamp": 1772998126,
          "last_comment_name": null,
          "last_comment_uid": 0,
          "comment_count": 0
        },
        "full_name": {
          "title": "",
          "given": "Marge",
          "middle": "",
          "family": "Simpson",
          "generational": "",
          "credentials": ""
        },
        "preferred_name": "Marge"
      },
      "relationships": {
        "crm_contact_type": {
          "data": {
            "type": "crm_contact_type--crm_contact_type",
            "id": "4f268b9e-2bb4-4d80-86d0-b2af859531b7",
            "meta": {
              "drupal_internal__target_id": "person"
            }
          },
          "links": {
            "related": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/crm_contact_type?resourceVersion=id%3A4"
            },
            "self": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/relationships/crm_contact_type?resourceVersion=id%3A4"
            }
          }
        },
        "revision_uid": {
          "data": null,
          "links": {
            "related": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/revision_uid?resourceVersion=id%3A4"
            },
            "self": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/relationships/revision_uid?resourceVersion=id%3A4"
            }
          }
        },
        "emails": {
          "data": [
            {
              "type": "crm_contact_method--email",
              "id": "f79d5368-4c85-5823-8f90-aed1b6899379",
              "meta": {
                "primary": true,
                "drupal_internal__target_id": 7
              }
            }
          ],
          "links": {
            "related": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/emails?resourceVersion=id%3A4"
            },
            "self": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/relationships/emails?resourceVersion=id%3A4"
            }
          }
        },
        "telephones": {
          "data": [
            {
              "type": "crm_contact_method--telephone",
              "id": "a347f315-da26-507e-a94c-e0c47ac81888",
              "meta": {
                "primary": true,
                "drupal_internal__target_id": 49
              }
            }
          ],
          "links": {
            "related": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/telephones?resourceVersion=id%3A4"
            },
            "self": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/relationships/telephones?resourceVersion=id%3A4"
            }
          }
        },
        "addresses": {
          "data": [
            {
              "type": "crm_contact_method--address",
              "id": "9bd585b9-302f-5915-9227-a496c46b4c94",
              "meta": {
                "primary": true,
                "drupal_internal__target_id": 54
              }
            }
          ],
          "links": {
            "related": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/addresses?resourceVersion=id%3A4"
            },
            "self": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/relationships/addresses?resourceVersion=id%3A4"
            }
          }
        },
        "image": {
          "data": null,
          "links": {
            "related": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/image?resourceVersion=id%3A4"
            },
            "self": {
              "href": "https://crm.ddev.site/jsonapi/crm_contact/person/fb580b11-2796-55de-a006-a05492eabf02/relationships/image?resourceVersion=id%3A4"
            }
          }
        }
      }
    }
  ],
  "links": {
    "next": {
      "href": "https://crm.ddev.site/jsonapi/crm_contact/person?page%5Boffset%5D=2&page%5Blimit%5D=2"
    },
    "self": {
      "href": "https://crm.ddev.site/jsonapi/crm_contact/person?page%5Blimit%5D=2"
    }
  }
}

Help improve this page

Page status: No known problems

You can: