Overview
Many objects in the Contazen API contain references to other objects via their IDs. By default, these references are returned as simple ID strings. However, you can request the full objects by using theexpand
parameter.
Usage
Include theexpand
parameter in your request to retrieve related objects:
Supported Expansions
Invoices
When retrieving invoices, you can expand the following objects:Field | Description |
---|---|
lines | Invoice line items with full details |
payments | Payment records associated with the invoice |
client | Full client object instead of just client_id |
efactura | E-Factura submission details (if applicable) |
Example Without Expansion
Example With Expansion
Multiple Expansions
You can expand multiple objects in a single request:Performance Considerations
Expanding objects increases response size and processing time. Only expand objects when you need the additional data.
Best Practices
- Expand selectively - Only expand objects you actually need
- Cache expanded responses - Expanded objects change less frequently
- Use in detail views - Expand when showing single items, not lists
- Consider pagination - Be mindful of response size when expanding in list endpoints
List Endpoints
The expand parameter works with both individual object endpoints and list endpoints:When using expand with list endpoints, be aware that it will expand the objects for every item in the list, which can significantly increase response size.
Invalid Expansions
If you request an invalid expansion, it will be ignored. The API only expands valid fields:client
but ignore invalid_field
.