Skip to main content

Authentication

This section describes how to authenticate with Mico Voice AI API.

Step 1: Get your Client ID and secret from Mico Voice AI

  1. Login to micovoice.com.
  2. From the sidebar, click on “Organization”.
  3. Click the “Integrations” tab.
  4. Scroll down to “API Integration” section.
  5. Under “API Access Credential”, click "Generate credential”.
  6. Take note of Client ID and secret, you will use them for the next step.

Step 2: Obtain an Access Token

The client application must make a POST request to the token endpoint of the API server to obtain an access token.

Request Details:

  • Method: POST
  • URL: https://api.micovoice.com/oauth/token
  • Headers:
    • Content-Type: application/x-www-form-urlencoded
  • Body:
    • grant_type=client_credentials
    • client_id=<your_client_id>
    • client_secret=<your_client_secret>
    • scope="campaigns:write campaigns:read outbound_calls:write outbound_calls:read"

Resquest Details:

The response will return an access_token which can be used to access resources in the API.

Example response:

{
"access_token": "nzoPXvZLrEGuXRbxNfg9zAYUwTkiKHHxrAyFivypDELLtuJEqdDCTr9hVEfTcUXiky9LZGMsDAtxilHBXMUVJS",
"expires_in": 86399,
"token_type": "bearer"
}

Example using curl:

curl -X POST https://api.micovoice.com/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=YOUR_CLIENT_ID" \
--data-urlencode "client_secret=YOUR_CLIENT_SECRET" \
--data-urlencode "scope=outbound_calls:read campaigns:read campaigns:write outbound_calls:write"

Example using Javascript

const params = new URLSearchParams();
params.append("grant_type", "client_credentials");
params.append("client_id", "YOUR_CLIENT_ID");
params.append("client_secret", "YOUR_CLIENT_SECRET");
params.append("scope", "outbound_calls:write outbound_calls:read");

const response = await fetch("https://api.micovoice.com/oauth/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: params,
});

const data = await response.json();
const token = data.access_token;

Step 3: Use the Access Token

Include the access_token in the Authorization header of your API requests:

Header:

Authorization: Bearer <access_token>

Example using curl:

curl -X GET https://api.micovoice.com/v1/outbound_calls/${callUid} \
-H "Authorization: Bearer eyJhbGciOi...example-token..."

Example using javascript:

const callUid = 'your-call-uid';
const accessToken = 'eyJhbGciOi...example-token...';

fetch(`https://api.micovoice.com/v1/outbound_calls/${callUid}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Accept': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('API Response:', data);
})
.catch(error => {
console.error('Fetch error:', error);
});