Expanding Responses#
Many objects allow you to request additional information as an expanded response by using the expand parameter. This parameter is available on all API requests and applies to the response of that request only.
How It Works#
By default, related objects are returned as IDs:
{
"id": "pi_123456789",
"object": "payment_intent",
"customer": "cus_123456789",
"payment_method": "pm_123456789"
}With expand, the full object is included inline:
curl https://api.casapay.com/v1/payment_intents/pi_123456789?expand[]=customer&expand[]=payment_method \
-H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"{
"id": "pi_123456789",
"object": "payment_intent",
"customer": {
"id": "cus_123456789",
"object": "customer",
"name": "Jane Doe",
"email": "jane@example.com"
},
"payment_method": {
"id": "pm_123456789",
"object": "payment_method",
"type": "card"
}
}Nested Expansion#
You can expand nested objects using dot notation:
curl https://api.casapay.com/v1/payment_intents/pi_123456789?expand[]=customer.default_payment_method \
-H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"Expansion in List Requests#
You can expand objects within list responses using data prefix:
curl https://api.casapay.com/v1/payment_intents?expand[]=data.customer \
-H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"You can expand up to 4 levels deep and request a maximum of 10 expansions per request.