Expanding Responses
How to include related resources in responses.
|
Overview
Many resources contain references (IDs) to other resources. Use the expand query parameter to expand (inline) referenced objects in the response, reducing the need for additional API calls.
Usage
Specify the field names you want to expand as a comma-separated list in the expand query parameter.
# Expand company and contacts on a deal
curl https://api.blueai.jp/api/v1/crm/deals/deal_11111111111111111111111111111111?expand=company,contacts \
-b cookies.txtDefault Behavior
Without expand, related resources are returned as ID strings only. With expand, the corresponding fields are replaced with full objects.
Without expand
{
"id": "deal_11111111111111111111111111111111",
"name": "Big Deal",
"company_id": "comp_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}With ?expand=company
{
"id": "deal_11111111111111111111111111111111",
"name": "Big Deal",
"company": {
"id": "comp_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"name": "Acme Corp",
"domain": "acme.com"
}
}Supported Endpoints
The expand parameter is available on the following endpoints:
GET /api/v1/crm/deals— CRM Deals — can expand company, contactsGET /api/v1/crm/contacts— CRM Contacts — can expand company
Example
const res = await fetch(
"https://api.blueai.jp/api/v1/crm/deals?expand=company,contacts",
{ credentials: "include" },
);
const { data } = await res.json();
// company is now a full object instead of just an ID
console.log(data[0].company.name); // "Acme Corp"