Mint an agent token
curl --request POST \
--url https://infra.usegrade.com/api/email/sdk/v1/agent/token \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Application-Id: <api-key>' \
--data '
{
"end_user": "user_8f3a2c"
}
'import requests
url = "https://infra.usegrade.com/api/email/sdk/v1/agent/token"
payload = { "end_user": "user_8f3a2c" }
headers = {
"X-Application-Id": "<api-key>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Application-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({end_user: 'user_8f3a2c'})
};
fetch('https://infra.usegrade.com/api/email/sdk/v1/agent/token', 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://infra.usegrade.com/api/email/sdk/v1/agent/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'end_user' => 'user_8f3a2c'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Application-Id: <api-key>"
],
]);
$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://infra.usegrade.com/api/email/sdk/v1/agent/token"
payload := strings.NewReader("{\n \"end_user\": \"user_8f3a2c\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Application-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://infra.usegrade.com/api/email/sdk/v1/agent/token")
.header("X-Application-Id", "<api-key>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"end_user\": \"user_8f3a2c\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://infra.usegrade.com/api/email/sdk/v1/agent/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Application-Id"] = '<api-key>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"end_user\": \"user_8f3a2c\"\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"api_version": 1
}{
"success": false,
"code": "INVALID_REQUEST",
"message": "<string>"
}{
"success": false,
"code": "AGENT_DISABLED",
"message": "<string>"
}{
"success": false,
"code": "AGENT_UNCONFIGURED",
"message": "<string>"
}Grade AI
Mint an agent token
Trades the SDK key for an agent token for one person of yours, valid for 15 minutes. Requires the key’s agent:read scope and the assistant switched on for the organization. Your backend sends the token to the assistant and to its MCP reads; it never reaches a browser.
Mint an agent token
curl --request POST \
--url https://infra.usegrade.com/api/email/sdk/v1/agent/token \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Application-Id: <api-key>' \
--data '
{
"end_user": "user_8f3a2c"
}
'import requests
url = "https://infra.usegrade.com/api/email/sdk/v1/agent/token"
payload = { "end_user": "user_8f3a2c" }
headers = {
"X-Application-Id": "<api-key>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Application-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({end_user: 'user_8f3a2c'})
};
fetch('https://infra.usegrade.com/api/email/sdk/v1/agent/token', 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://infra.usegrade.com/api/email/sdk/v1/agent/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'end_user' => 'user_8f3a2c'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Application-Id: <api-key>"
],
]);
$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://infra.usegrade.com/api/email/sdk/v1/agent/token"
payload := strings.NewReader("{\n \"end_user\": \"user_8f3a2c\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Application-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://infra.usegrade.com/api/email/sdk/v1/agent/token")
.header("X-Application-Id", "<api-key>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"end_user\": \"user_8f3a2c\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://infra.usegrade.com/api/email/sdk/v1/agent/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Application-Id"] = '<api-key>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"end_user\": \"user_8f3a2c\"\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"api_version": 1
}{
"success": false,
"code": "INVALID_REQUEST",
"message": "<string>"
}{
"success": false,
"code": "AGENT_DISABLED",
"message": "<string>"
}{
"success": false,
"code": "AGENT_UNCONFIGURED",
"message": "<string>"
}Beta. The assistant API and its reads over MCP are in beta. They are open to every
organization that pays out through Grade, and parts are not available yet, as each page says.
Body
application/json
Who is asking.