Use custom attributes with API
Most custom attribute functions are done through the user interface (UI). You can, however, create a company with custom attributes through the API.
All other functions for company, user, order, lead, purchase, and subscription custom attributes must be done through the UI.
Before you create a company with custom attributes, you first have to create the custom attribute in the UI. See Create custom attributes.
Use the details from the custom attributes that you created in the UI to create a company with a custom attribute.
The following table maps the fields in the UI with the custom attributes parameters.
UI field | Request Parameter |
---|---|
Key | "name" |
Label | "label" |
Hint | "hint" |
Input Type, Text | "attributeType": "TEXT" |
Input Type, Checkboxes | "attributeType": "MULTISELECT" |
Options | "valueKeys" |
For information on how to create a company through the API, see Create a new company.
Create a company with custom attributes
The following example request and response demonstrate how to create a company with custom attributes.
Request
{
"name": "Webprix",
"defaultRole": "USER",
"firstUser": {
"activated": false,
"email": "roberta.simpson@webprix.com",
"firstName": "Roberta",
"lastName": "Simpson",
"roles": [
"ROLE_USER"
],
"userName": "roberta.simpson"
},
"countryCode": "US",
"customAttributes": [
{
"name": "headquarters",
"value": "New York"
},
{
"name": "Locations",
"attributeType": "MULTISELECT",
"label": "Company locations",
"hint": "Storefront locations",
"valueKeys": [
"Montreal",
"New York",
"San Diego"
]
}
]
}
Response
{
"uuid": "b55adcb7-9dc3-4e05-ab57-f4f14821448e",
"name": "Webprix",
"enabled": true,
"address": null,
"companySize": null,
"customAttributes": [
{
"name": "headquarters",
"value": "New York"
},
{
"name": "Locations",
"attributeType": "MULTISELECT",
"label": "Company locations",
"hint": "Storefront locations",
"valueKeys": [
"New York",
"San Diego",
"Montreal"
]
}
],
"creationDate": 1565705679871,
"industry": null,
"salesAgent": null,
"emailAddress": null,
"website": null,
"picture": null,
"vendor": false,
"reseller": false,
"channelAdmin": false,
"externalId": null,
"phoneNumber": null,
"defaultRole": "USER",
"countryCode": "US",
"status": "INACTIVE",
"thirtyDaysPurchaseLimitExempt": false,
"thirtyDaysPurchaseLimitOverrideAmt": null,
"dailyPurchaseLimitExempt": false,
"dailyPurchaseLimitOverrideAmt": null,
"importAppsEnabled": false,
"onlyAdminsCanBuy": false,
"firstUser": {
"email": "roberta.simpson@webprix.com",
"firstName": "Roberta",
"lastName": "Simpson",
"roles": [
"USER"
]
}
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!