Create a company
In order, to start the process, we need to create our first company. To do this, it's pretty simple. A simple name is required to achieve the creation.
- name: The company name. It will be used in the various displays we provide.
- cURL
- NodeJS
curl -X POST
-H "Authorization: Bearer <APIKEY>"
-H "Content-Type: application/json"
-d '{"name": ""}'
{{baseUrl}}/api/companies
const axios = require('axios');
const baseUrl = "{{baseUrl}}/api/companies";
const apiKey = "YOUR API KEY";
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
const data = {
name: "My First Company"
};
axios.post(baseUrl, data, { headers: headers })
.then(response => {
console.log('Status Code:', response.status);
console.log('Response Data:', response.data);
})
.catch(error => {
console.error('Error:', error.response.status);
console.error('Error Data:', error.response.data);
});
If everything works fine, API should return you this data.
{
"id": "ObjectID"
"name": "My First Company",
"partnerId": "ObjectID",
"updatedAt": "2019-08-24T14:15:22Z",
"createdAt": "2019-08-24T14:15:22Z",
}
tip
You'll need the company ID in all the next APIs calls, so make sure to store it in your database.