Archive and restore an agent
Summary
This guide archives an agent, finds it in the archived list and restores it before it is deleted.
It covers archiveAgent, the archive window and unarchiveAgent. It does not cover phone number
assignment after a restore; see Route phone calls.
Facts
Steps
Set AGENT_ID to the id of the agent, from listAgents or from the answer of createAgent.
1. Archive the agent
The answer is the agent with state: archived, archived_at and archive_deadline. From this
moment:
- The agent takes no new calls.
- Its phone numbers are released. They keep their history and you can assign them to another agent.
- Draft edits, publication and rollback answer
409 agent_archived. listAgentsleaves the agent out unless you ask forstate=archived.getAgentstill reads it by ID.
2. Find archived agents
Each item shows its archive_deadline. From that time, the agent and its configuration are
deleted for good. Call evidence is kept, hidden. After the deletion, the agent reads as
404 not_found.
3. Restore the agent
The agent returns to its state before the archive: draft, live or paused. A live agent
takes calls again at once. archived_at and archive_deadline are null again. The released phone
numbers are not assigned again: assign them with the phone number operations.
Rules
- MUST let running work end before you archive. While a call, a campaign or another job of the
agent runs, archive answers
409 archive_blocked. - MUST send a new
Idempotency-Keyafterarchive_blocked, because the first attempt had no effect. - MUST unarchive before the deletion starts. Unarchive works until then, also after
archive_deadlinewhile a running call, campaign or legal hold delays the deletion. - MUST NOT expect archive to keep the agent’s phone numbers. Assign them again after a restore.
- Any key or member of the workspace can unarchive an agent, whoever archived it.
Verify
Expected output after step 3: the agent with its earlier state and no archive dates.
Errors
details.reason of archive_blocked is an open vocabulary: treat an unknown value like the ones
above and retry after the work ends.