Applications
API Keys
API keys are like credentials that identify and authorize access to our API, we use a client_credential OAauth2.0 workflow with client_id and client_secret, saved under our terms, to authorize requests on endpoints.
It's important to note that we always add the cbx_b2b_ prefix to the clientId of all credentials created on the platform. You can always consult your credentials in the "API Keys" menu.
Application [POST]
https://api-b2b.carbonext.com.br/v1/customers/applications
This endpoint creates a new application key, which is used to create Machine to Machine (M2M) integrations, we advise using one for each API you need to integrate with ours.
customer_applications_write
Request attributes
| Parameter | Description | 
|---|---|
| clientId | The generated client Id | 
| displayName | The client's name | 
| permissions | An array of an object that contains the application's permissions | 
Response attribute
| Parameter | Description | 
|---|---|
| id | The application ID in the database | 
| clientId | User ID code | 
| clientSecret | Code used together with the client_id to grant authorization to the user | 
Example Request
var axios = require('axios');
var data = JSON.stringify({
        "clientId": "myapp_name",
        "displayName": "My test app",
        "permissions": [
                {
                        "id": "45bbe1bc-4d5a-4991-baac-42fa95d35824"
                },
                {
                        "id": "65c514f4-424f-4c82-9827-482d564091c0"
                }
        ]
});
var config = {
        method: 'post',
        url: 'https://api-b2b-hml.carbonext.com.br/v1/customers/applications?customer-id=d762a683-cb74-43a4-979a-6579dc53cec1',
        headers: { 
                'Authorization': 'Bearer <access_token>', 
                'Content-Type': 'application/json'
        },
        data : data
};
axios(config)
        .then(function (response) {
                console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
                console.log(error);
        });
Example Response
{
        "id": "21be1e66-307e-47a7-914e-c1a8a68f269c",
        "clientId": "cbx_b2b_myapp_name",
        "clientSecret": "1d49c575-81f8-4d8c-bc18-93711cf7eb24"
}
List Applications [GET]
https://api-b2b-hml.carbonext.com.br/v1/customers/applications?page=2&page-size=10
This endpoint returns a paginated list of API keys.
customer_applications_write
customer_applications_read
Response attributes
| Attributes | Description | 
|---|---|
| items | An array of paginated applications from the customer | 
Example Request
var axios = require('axios');
var qs = require('qs');
var config = {
        method: 'get',
        url: 'https://api-b2b-hml.carbonext.com.br/v1/customers/applications',
        headers: { 
                'Authorization': 'Bearer <access_token>'
        }}
axios(config)
        .then(function (response) {
                console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
                console.log(error);
        });
Example Response
{
        "items": [
                {
                        "id": "21be1e66-307e-47a7-914e-c1a8a68f269c",
                        "clientId": "cbx_b2b_myapp_name",
                        "displayName": "My test app44"
                },
        ],
        "pageIndex": 1,
        "totalPages": 1,
        "totalCount": 1,
        "aggregations": null,
        "hasPreviousPage": false,
        "hasNextPage": false
}
Fetch an API [GET]
https://api-b2b.carbonext.com.br/v1/customers/applications/:id
This endpoint returns an API key object with your permissions.
customer_applications_write
customer_applications_read
Response attributes
| Attributes | Description | 
|---|---|
| Application | An application object | 
Example Request
var axios = require('axios');
var config = {
        method: 'get',
        url: 'https://api-b2b-hml.carbonext.com.br/v1/customers/applications/02c75cc5-b575-4b5f-87d8-bf09e6009c23',
        headers: { 
                'Authorization': 'Bearer <access_token>'
        }
};
axios(config)
        .then(function (response) {
                console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
                console.log(error);
        });
Example Response
{
        "id": "02c75cc5-b575-4b5f-87d8-bf09e6009c23",
        "clientId": "cbx_b2b_myapp_name",
        "displayName": "My test app",
        "permissions": [
                {
                        "id": "781d50ae-ab86-4988-8d39-48dca58da6a6",
                        "name": "default-roles-co2free",
                        "description": null,
                        "composite": true,
                        "clientRole": false,
                        "containerId": "CO2FREE",
                        "attributes": null
                }
        ]
}
id: 02c75cc5-b575-4b5f-87d8-bf09e6009c23