Authenticate

📘

This example uses the https://api.sandbox.caliza.com/core-api/v1 base URL. Examples are provided in multiple languages (cURL, JavaScript, Python). If you're using Postman, Swagger, or any other API Graphical User Interface, use this URL to follow this guide.

To authenticate with the Caliza API, you'll need to obtain your credentials first. Follow these steps:

  1. Access your Caliza dashboard at https://web.sandbox.caliza.com
  2. On your dashboard, access your Profile information by clicking on Personal menu > Profile.
  3. On the Profile screen, select step 2, Client Info.
  4. Copy the Client ID and the Client Secret.

Once you have your credentials, you can authenticate using any of the following methods. Replace the placeholders ({{CLIENT_ID}}, {{CLIENT_SECRET}}, {{USERNAME}}, and {{PASSWORD}}) with your actual values:

curl --location --request POST 'https://api.sandbox.caliza.com/auth/realms/caliza/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id={{CLIENT_ID}}' \
--data-urlencode 'client_secret={{CLIENT_SECRET}}' \
--data-urlencode 'username={{USERNAME}}' \
--data-urlencode 'password={{PASSWORD}}'
const response = await axios.post(
  'https://api.sandbox.caliza.com/auth/realms/caliza/protocol/openid-connect/token',
  new URLSearchParams({
    grant_type: 'password',
    client_id: '{{CLIENT_ID}}',
    client_secret: '{{CLIENT_SECRET}}',
    username: '{{USERNAME}}',
    password: '{{PASSWORD}}'
  }),
  {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }
);

console.log('Access Token:', response.data.access_token);
import requests

    response = requests.post(
      'https://api.sandbox.caliza.com/auth/realms/caliza/protocol/openid-connect/token',
      headers={'Content-Type': 'application/x-www-form-urlencoded'},
      data={
        'grant_type': 'password',
        'client_id': '{{CLIENT_ID}}',
        'client_secret': '{{CLIENT_SECRET}}',
        'username': '{{USERNAME}}',
        'password': '{{PASSWORD}}'
      }
    )

    token_data = response.json()
    print('Access Token:', token_data['access_token'])

All three methods above return the same JSON response:

{
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ0Z3V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iOiJmOWE5ODI4NC1iMzRlLTRiMzAtYjdhZS00OWRkNmNmYzZhOGEiLCJ0eXAiOiJSZWZyZXNoIiwiYXpwIjoiaW50ZWdyYXRvci1Xcml0ZUNob2ljZS1Hcm91cC0yLWY0NmYzZmUzLTAzOTAtNGQ1NS04MTFhLTE2NDcxYzc0YjZlMSIsInNlc3Npb25fc3RhdGUiOiJjOTE5NGViMi04M2NkLTRlODYtOGU5Ni1hZWYxOGE0NjY4YWUiLCJzY29wZSI6ImVtYWlsIG9wZW5pZCBwcm9maWxlIiwic2lkIjoiYzkxOTRlYjItODNjZC00ZTg2LThlOTYtYWVmMThhNDY2OGFlIn0.siKyXuWAarbs2schgFV2sW71pF__PjPNgY68PXBoTOg",
    "token_type": "Bearer",
    "not-before-policy": 0,
    "session_state": "c9194eb2-83cd-4e86-8e96-aef18a4668ae",
    "scope": "email openid profile"
}

The response contains your authentication token. You will find the access_token field in the response, which you'll use to authenticate all subsequent API requests.

💡

Extracting the token: In JavaScript, access the token via response.data.access_token. In Python, use response.json()['access_token']. For cURL, parse the JSON response to extract the access_token field.

Now you have an access token that's ready to access and operate with the Caliza API. Include this token in the Authorization header of all subsequent API requests as Authorization: Bearer {{ACCESS_TOKEN}}.

Next steps