10.2. Inviting companies to the platform with cURLΒΆ
This example shows how to send contact invitations to companies. If the invited company accepts this invitation, both companies become connected and can start exchanging documents with each other. The following example is a cURL request using bearer token for request authorization.
curl --location --request POST 'https://cargox.digital/api/v3/companies/self/contacts/' \
--header 'Authorization: Bearer acaYpzlT7OL6gw1yI9W1ovtTZtFmQa' \
--header 'Content-Type: application/json' \
--data-raw '[{"email": "[email protected]", "message": "Personalized message."},
{"email": "[email protected]"},
{"email": "[email protected]"}]'
Request body is a list of objects in JSON format. Each object must have an email
property and can have an optional
message
property. If the bearer token is valid, an invitation email is sent to the email
address with the optional
personalized message
. The above cURL request returns the following JSON response:
{
"successful_invites": [
{
"company_id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662",
"company": {
"name": "Inviter company",
"branch": null,
"address": "Sample street 123",
"address2": "",
"postal_code": "1234",
"city": "Ljubljana",
"country": "SI",
"country_name": "Slovenia",
"website": "https://cargox.io",
"vat_number": null,
"logo": null,
"logo_name": "",
"id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662"
},
"my_inbox_id": "96bf8b27-65fb-4c46-9f10-067441916eaa",
"their_inbox_id": null,
"their_inbox": null,
"email": "[email protected]",
"message": "Personalized message.",
"note": null,
"invitation_code": null,
"status": "pending",
"created": "2020-07-27T13:16:26.981797Z",
"created_by_id": "55ba1326-e07f-4293-b3b3-84db9f6efb90",
"created_by": {
"name": "John Smith",
"first_name": "John",
"last_name": "Smith",
"email": "[email protected]",
"telephone": null,
"company_id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662",
"company": {
"name": "Inviter company",
"branch": null,
"address": "Sample street 123",
"address2": "",
"postal_code": "1234",
"city": "Ljubljana",
"country": "SI",
"country_name": "Slovenia",
"website": "https://cargox.io",
"vat_number": null,
"logo": null,
"logo_name": "",
"id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662"
},
"logo": null,
"logo_name": "",
"id": "0102f020-6307-4a60-b7bb-c8a7dbea4d9d"
},
"resolved": null,
"resolved_by_id": null,
"resolved_by": null,
"contact_person": null,
"id": "e59c2621-bba4-4b40-b503-f8a88674f8ee"
}
],
"failed_invites": [
{
"email": "[email protected]",
"message": "",
"error": "Company is already invited."
},
{
"email": "[email protected]",
"message": "",
"error": "The domain domain-does-not-exist.com could not be found."
}
]
}
Response consists of two lists named successful_invites
and failed_invites
. The first is a list of serialized
Contact
object that were created as a result of successfully sent invitations. The latter is a a list of invitation
objects that could not be successfully processed. Reason for failure is listed under the error
property in each object.
If bearer token is invalid or expired, the following 403 Forbidden
response is returned:
{
"detail": "Authentication credentials were not provided."
}