curl --request POST \
--url https://api.customer.com/sarvam/byok/v1/auth \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-request-id: <x-request-id>' \
--header 'x-request-timestamp: <x-request-timestamp>' \
--data grant_type=client_credentialsimport requests
url = "https://api.customer.com/sarvam/byok/v1/auth"
payload = { "grant_type": "client_credentials" }
headers = {
"x-request-id": "<x-request-id>",
"x-request-timestamp": "<x-request-timestamp>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-request-id': '<x-request-id>',
'x-request-timestamp': '<x-request-timestamp>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({grant_type: 'client_credentials'})
};
fetch('https://api.customer.com/sarvam/byok/v1/auth', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.customer.com/sarvam/byok/v1/auth",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=client_credentials",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/x-www-form-urlencoded",
"x-request-id: <x-request-id>",
"x-request-timestamp: <x-request-timestamp>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.customer.com/sarvam/byok/v1/auth"
payload := strings.NewReader("grant_type=client_credentials")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-request-id", "<x-request-id>")
req.Header.Add("x-request-timestamp", "<x-request-timestamp>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.customer.com/sarvam/byok/v1/auth")
.header("x-request-id", "<x-request-id>")
.header("x-request-timestamp", "<x-request-timestamp>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.customer.com/sarvam/byok/v1/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-request-id"] = '<x-request-id>'
request["x-request-timestamp"] = '<x-request-timestamp>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=client_credentials"
response = http.request(request)
puts response.read_body{
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"token_type": "Bearer",
"expires_in": 3600
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}Obtain Access Token
If using the Client Credentials method, Samvaad will call this endpoint to exchange its Client ID and Client Secret for a short-lived JWT Bearer token.
Samvaad will authenticate to this endpoint using HTTP Basic Authentication. The returned access token will be cached and used in the Authorization header for all subsequent API calls until it expires.
Note: This endpoint is not needed if you opt for the static API Key authentication method.
curl --request POST \
--url https://api.customer.com/sarvam/byok/v1/auth \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-request-id: <x-request-id>' \
--header 'x-request-timestamp: <x-request-timestamp>' \
--data grant_type=client_credentialsimport requests
url = "https://api.customer.com/sarvam/byok/v1/auth"
payload = { "grant_type": "client_credentials" }
headers = {
"x-request-id": "<x-request-id>",
"x-request-timestamp": "<x-request-timestamp>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-request-id': '<x-request-id>',
'x-request-timestamp': '<x-request-timestamp>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({grant_type: 'client_credentials'})
};
fetch('https://api.customer.com/sarvam/byok/v1/auth', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.customer.com/sarvam/byok/v1/auth",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=client_credentials",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/x-www-form-urlencoded",
"x-request-id: <x-request-id>",
"x-request-timestamp: <x-request-timestamp>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.customer.com/sarvam/byok/v1/auth"
payload := strings.NewReader("grant_type=client_credentials")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-request-id", "<x-request-id>")
req.Header.Add("x-request-timestamp", "<x-request-timestamp>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.customer.com/sarvam/byok/v1/auth")
.header("x-request-id", "<x-request-id>")
.header("x-request-timestamp", "<x-request-timestamp>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("grant_type=client_credentials")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.customer.com/sarvam/byok/v1/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-request-id"] = '<x-request-id>'
request["x-request-timestamp"] = '<x-request-timestamp>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "grant_type=client_credentials"
response = http.request(request)
puts response.read_body{
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"token_type": "Bearer",
"expires_in": 3600
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service is currently unavailable."
}
}Authorizations
HTTP Basic authentication for the /auth endpoint, using the Client ID as the username and the Client Secret as the password.
Headers
A unique identifier for this specific API call, generated by the client (Samvaad).
An identifier to trace a single request across multiple services.
The ISO 8601 timestamp of when the client sent the request.
Body
The request body must specify the grant type as 'client_credentials'.
The OAuth2 grant type. Must be client_credentials.
"client_credentials"
Response
Authentication successful. Returns a JWT access token.
The response from a successful authentication request.
Show child attributes
Show child attributes