Supplements API – Cordial Knowledge Base
How can we help?
Overview
The supplements collection contains one or more supplemental data sets. Supplements extend the Cordial data model and support a range of additional data related to your business.
- API set name: supplements
Example supplements use case
A clothing company may have a supplement namedproductsthat is meant to store records associated with each product they sell. Theproductssupplement may have an arbitrary set of fields like SKU, name, color, category, and location to represent the attributes about clothing. Each item in the company's product catalog is then represented as a record with field/value pairs describing that item's attribute details.
Additional information
- Supplements and fields may be added at any time to your database and are immediately available to all contacts once created.
- Supplement IDs must be unique.
- Supplement IDs cannot be 24-character hex strings. This format is reserved for system use.
- Fields that will be used for search or audience building must be indexed. This is accomplished by including each field in the indexed array.
- Indexed field names within a supplement must be unique. However, the same field name can be used within different supplements.
- Individual supplement record index values cannot exceed 1024 bytes.
- Certain special characters may be interpreted as boolean operators when stored within indexed fields, which can cause supplement data query failures. We recommend omitting special characters altogether from indexed field data.
- Non-indexed fields can be entered as additional field/value pairs in the JSON or as columns within an import file.
- Indexed field definitions will enforce the type validations on record load and update. Non-indexed will not, nor will they undergo validation. This enables storing and maintaining wide latitudes of data both structured and unstructured.
- Sparse indexes are available in supplements. Learn more.
Authentication
Cordial's core APIs use HTTPS Basic Authentication (BA). From within the Cordial platform, you can generate an encoded API key for your account and use it for authorization.
Resource associations
The following resource collections are associated to this collection.
| Collection | Association |
|---|---|
| contacts | Supplements data can be associated back to a contact if the contactId is stored in a record. |
Methods, parameters, and examples
- POST/v2/supplements
- GET/v2/supplements
- GET/v2/supplements/{key}
- PUT/v2/supplements/{key}
- DELETE/v2/supplements/{key}
- POST/v2/supplements/{supplement}/imports
- POST/v2/supplements/{supplement}/records
- GET/v2/supplements/{supplement}/records
- PUT/v2/supplements/{supplement}/clear
- GET/v2/supplements/{supplement}/records/{id}
- PUT/v2/supplements/{supplement}/records/{id}
- DELETE/v2/supplements/{supplement}/records/{id}
POST/v2/supplements
| Method | URL Path |
|---|---|
| POST | /v2/supplements |
| - Creates a new supplement in the Cordial database using the appropriate JSON body. - Fields that will serve as search indexes need to be placed in the indexed array of fields. Additional non-indexed fields can be added in the JSON records, or by declaring the field as a column in an import file. - Posting more than one time for the same supplement key will generate an error. |
*Required
| Parameter | Type | Description | Example |
|---|---|---|---|
| ### Supplement | |||
| * key | string | Unique supplement identifier. | products |
| name | string | The name of the supplement. | Products |
| contactObject | boolean | Enables the use of this supplement as a contact attribute for audience segmentation. Possible values: true or false. | true |
| ### indexes (array) Individual supplement record index values cannot exceed 1024 bytes. Sparse indexes are available. |
|||
| * field | string | The name of the field. Required to be unique within the context of this supplement only. | item |
| * type | string | Defines the field's data type. Options include: string, number, date, geo, or array. | string |
The following will create a new supplement for products with the indexed fields of item, category, and color. This supplement is not contact attribute enabled.
{
"key": "products",
"name": "Products",
"contactObject": false,
"indexes": [
{
"field": "item",
"type": "string"
},
{
"field": "category",
"type": "string"
},
{
"field": "color",
"type": "string"
}
]
}
The following URL in conjunction with the JSON will perform the POST.
https://<path>/supplements
GET/v2/supplements
| Method | URL Path |
|---|---|
| GET | /v2/supplements |
| - Retrieves all supplements from the Cordial database. - When retrieving a large amount of supplements in the response, it is possible to apply the per_page and page query string parameters to limit the count returned and page position. |
Return all supplements: The following URL will retrieve all supplements and include all fields.
https://<path>/v2/supplements
Return supplements filtered by page number and records per page: The following URL will retrieve all supplements starting from page 3 grouping contacts by 10. For example, page 1 would have included the first 10, page 2 the second group of 10 and so on.
https://<path>/v2/supplements?page=3&per_page=10
GET/v2/supplements/{key}
| Method | URL Path |
|---|---|
| GET | /v2/supplements/{key} |
| - Retrieves a supplement from the Cordial database. - The supplement is defined by the supplement's unique key value.- For example, /supplements/cars would return the response data for the supplement with the key of products. |
The following URL will retrieve the supplement with the key of products, and include all indexed fields.
https://<path>/v2/supplements/products
PUT/v2/supplements/{key}
| Method | URL Path |
|---|---|
| PUT | /v2/supplements |
| Updates a supplement in the Cordial database using the appropriate JSON body. |
When a supplement index field is passed, its data type (string, integer, etc.) will be recognized and searchable in the platform UI. If the field data type is later changed, any new supplement values for that field will not be searchable in the UI. It is necessary to create a new field with the updated data type if the values are to be searchable in the platform UI.
Same requirements and schema as the POST method above.
The following will update the supplement for product with the indexed fields of item, category, color, and sales.
{
"name": "products",
"indexes": [
{
"field": "item",
"type": "string"
},
{
"field": "category",
"type": "number"
},
{
"field": "color",
"type": "number"
},
{
"field": "sales",
"type": "array"
}
]
}
The following URL in conjunction with the JSON will perform the PUT.
https://PUT/v2/supplements/products
DELETE/v2/supplements/{key}
| Method | URL Path |
|---|---|
| DELETE | /v2/supplements/{key} |
| - Deletes a supplement from within the Cordial database. - The supplement is defined by the supplement's unique key value.- For example, /supplements/products would delete the supplement with the key value of products. |
The following URL will delete the supplement with the key value of cars.
https://<path>/v2/supplements/products
POST/v2/supplements/{supplement}/imports
| Method | URL Path |
|---|---|
| POST | /v2/supplements/{supplement}/imports |
| - Creates a supplement data import job using the JSON body information. - Permissible import file types: CSV and JSONL. - The import file must contain an id field that uniquely identifies each record in a supplement. By default, existing supplements records are overwritten and new supplements are added.- Column headers can include one or more indexed fields along with any other optional non-indexed fields of your choosing. - If needed, an optional email confirmation can be set to trigger upon completion. This is helpful for larger imports. |
- Required
| Parameter | Type | Description | Example |
|---|---|---|---|
| * transport | string | Transport options include HTTP, FTP, SFTP, s3, or Snowflake. Note that HTTP also incorporates HTTPS. | http |
| * url | string | URL or location of the import file. | https://files.example.com/123 |
| server | string | Defines FTP or SFTP when using a file transport protocol (FTP) transport. | ftp |
| username | string | An account username for gaining access to the file location. | file-access-acct |
| password | string | The account password for the above user name. | Msm1th$99! |
| port | string | if transport = FTP or SFTP, and not using default | 44 |
| path | string | Options are FTP, SFTP and s3 only | ftp |
| aws_access_key_id | string | if transport = s3, public AWS id | asdf9g8asg89gd |
| aws_secret_access_key | string | if transport = s3, secret AWS key | dudhKDDHE476383kdsdhdkasK |
| aws_bucket | string | if transport = s3, AWS bucket name | some-bucket |
| aws_region | string | if transport = s3, AWS region | us-west-2 |
| job | |||
| confirmEmail | string | Email address to send confirmation status message. | msmith@example.com |
| strategy | string | Options are insertOnly and updateOnly. If a strategy is not provided, by default records will be inserted and updated. | updateOnly |
| * hasHeader | boolean | Required if columns is not included. Denotes the first row column headers are present, default is false. | true |
| * columns | array | Required, if hasHeader is not explicitly set to true. Array of column headers, ordered by column positionally left to right. |
["item", "category", "color"] |
| nullMarker | string | Defines the value to use for ignoring or skipping attribute updates. Upon import, if an attribute contains the nullMarker value (i.e. skip), then the attribute will be skipped or ignored. |
skip |
| delimiter | string | Defines the data separation delimiter. | , - comma : - colon \t - tab |
| importName | string | Import job name that will be displayed alongside the job ID in the Jobs Widget. May only contain letters, numbers, and dashes. Does not accept whitespaces. | ContactImport-7-31 |
Specifying the `