curl --request POST \
--url https://api.bland.ai/v1/agents/{agent_id}/authorize \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"request_data": {}
}
'{
"token": "22480c52-0ff1-4214-bcb7-50649b508432"
}
Create a single-use session token for a client to talk with your web agent.
curl --request POST \
--url https://api.bland.ai/v1/agents/{agent_id}/authorize \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"request_data": {}
}
'{
"token": "22480c52-0ff1-4214-bcb7-50649b508432"
}
import { BlandWebClient } from 'bland-client-js-sdk';
const agentId = 'YOUR-AGENT-ID';
const sessionToken = 'YOUR-SESSION-TOKEN';
document.addEventListener('DOMContentLoaded', async () => {
document.getElementById('btn').addEventListener('click', async () => {
const blandClient = new BlandWebClient(
agentId,
sessionToken
);
await blandClient.initConversation({
sampleRate: 44100,
});
});
});
api.bland.ai domain.{
"name": "John Doe"
}
success or error.{
"token": "22480c52-0ff1-4214-bcb7-50649b508432"
}
Was this page helpful?