curl --request POST \
--url https://app.sapientpriors.com/api/v2/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_config": {
"role": "<string>",
"objective": "<string>",
"metadata": {}
}
}
'import requests
url = "https://app.sapientpriors.com/api/v2/agents"
payload = { "agent_config": {
"role": "<string>",
"objective": "<string>",
"metadata": {}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_config: {role: '<string>', objective: '<string>', metadata: {}}})
};
fetch('https://app.sapientpriors.com/api/v2/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"agent_id": "<string>",
"status": "initializing",
"agent_config": {
"role": "<string>",
"objective": "<string>",
"metadata": {}
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"visibility": "public",
"access": "owner"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}Create agent
Create an agent. Returns 202 while it initializes; poll the Location until status is ready.
curl --request POST \
--url https://app.sapientpriors.com/api/v2/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_config": {
"role": "<string>",
"objective": "<string>",
"metadata": {}
}
}
'import requests
url = "https://app.sapientpriors.com/api/v2/agents"
payload = { "agent_config": {
"role": "<string>",
"objective": "<string>",
"metadata": {}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_config: {role: '<string>', objective: '<string>', metadata: {}}})
};
fetch('https://app.sapientpriors.com/api/v2/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"agent_id": "<string>",
"status": "initializing",
"agent_config": {
"role": "<string>",
"objective": "<string>",
"metadata": {}
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"visibility": "public",
"access": "owner"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>",
"details": "<string>"
}Authorizations
An API key, shaped spk_<key_id>_<secret><checksum>, sent as Authorization: Bearer spk_.... Each key belongs to one project and reaches only that project: an id from another project answers 404.
- A service account's key runs your product. It acts as the service account, with the role the service account holds in the project, and keeps working when people leave. It reaches the project's public agents, never a private one. Only this key may send
X-SP-End-User. - A personal key acts as the person who created it, with their role in the project. It is for building and testing: every response carries
X-SP-Warning: personal API key, not for production, andX-SP-End-Useris refused with 400.
Keys are created and revoked on the API keys page of the Priors application. No API endpoint creates or revokes a service account's key. A personal key lasts 30, 90, or 365 days (90 by default), and a person can hold 10 live personal keys in an organization. A service account's key lasts 90 or 365 days (365 by default), and a service account can hold 5 live keys. The secret is shown once, at creation, and cannot be recovered.
A personal key made before projects (spu_...) keeps working until it expires, in its organization's Default project.
Keep keys on your server: a request with a Sec-Fetch-Site header is refused with 400, and Priors sends no CORS headers.
Body
The new agent's config and who may reach it.
Who can reach the agent.
public: everyone with a role in the agent's project, and the project's service account keys.private: its creator, the project's Project admins and the organization's Org admins. Service account keys never reach it.
Only a Project admin or an Org admin creates a public agent; anyone else naming it gets 403. Left out, the agent is public for them and private for anyone else. A service account's agents are always public: its key naming private gets 400.
public, private Response
Successful Response
A memory agent, without its threads.
How the caller reaches the agent:
owner: they own it.member: they were given access, and reach every thread.organization: a member of its organization reaching a discoverable agent not shared with them. They reach only the threads they created.
owner, member, organization