Replace an agent draft
Replaces the whole draft and returns the agent with a new revision.
PUT
Replaces the whole draft and returns the agent with a new revision. The request names the revision it read; a stale revision returns 409. Published versions, and the conversations answered on them, do not change. An endpoint answers for one agent at a time: a draft that names an endpoint another agent answers on returns 409. A draft that pins a catalog model returns 402 unless your plan is Growth or Scale, and 422 when the model is not available or does not support the reasoning level.
apiKeyheader
x-api-key<token>id*stringMatch
^agt_[0-9a-hjkmnp-tv-z]{16,24}$application/json- body
revision*stringLength
1 <= lengthdefinition*Agent
application/json- response
id*AgentIdMatch
^agt_[0-9a-hjkmnp-tv-z]{16,24}$name*stringsetupJob*|nullnamespaceId*|nullrevision*stringdraft*publishedVersion*|nullpublishedAt*string|nullpausedAt*string|nullcreditsPausedAt?string|null|nullmonthlySpendCapDollars*number|nullspend*createdAt*stringupdatedAt*stringimport { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.agents.replaceDraft({
"id": "example",
"revision": "example",
"definition": {
"instructions": "example",
"knowledge": "example",
"endpointIds": [
"example"
],
"integrations": [
{
"integrationId": "example",
"tools": {
"kind": "all"
}
}
],
"policy": {
"presets": [
"example"
],
"rules": [
{
"match": {},
"decide": "run"
}
]
},
"model": "standard",
"reasoning": "auto",
"workingHours": {
"timeZone": "example",
"ranges": [
{
"day": "monday",
"opens": "example",
"closes": "example"
}
]
},
"takeoverTimeoutMinutes": 1
}
});Example Response
{
"id": "string",
"name": "string",
"setupJob": "support",
"namespaceId": "string",
"revision": "string",
"draft": {
"instructions": "string",
"knowledge": "string",
"knowledgeSourceIds": [
"string"
],
"endpointIds": [
"string"
],
"integrations": [
{
"integrationId": "string",
"tools": {
"kind": "all"
}
}
],
"policy": {
"presets": [
"string"
],
"rules": [
{
"match": {
"kind": "send",
"effect": "read",
"channel": "sms",
"integration": "string",
"tool": "string",
"subject": "agent"
},
"note": "string",
"decide": "run",
"atLeast": null
}
],
"instructions": "string"
},
"model": "standard",
"reasoning": "auto",
"workingHours": {
"timeZone": "string",
"ranges": [
{
"day": "monday",
"opens": "string",
"closes": "string"
}
]
},
"takeoverTimeoutMinutes": 1
},
"publishedVersion": -9007199254740991,
"publishedAt": "string",
"pausedAt": "string",
"creditsPausedAt": "string",
"monthlySpendCapDollars": 0,
"spend": {
"month": "string",
"spentDollars": 0,
"capReachedAt": "string"
},
"createdAt": "string",
"updatedAt": "string"
}