diagram-projectAgents & Context Graphs

Define agent personas and versioned context graphs (state machines) that power conversation flows.

Manage the core agent definitions and context graphs that power your organization's AI services. Agents define the persona and behavior of your AI, while context graphs define the conversational flow and state management.

circle-info

API Terminology In the API, context graphs are called service_hierarchical_state_machine. Throughout this documentation we use the platform name "Context Graph" but note the API field name where relevant. See Core Concepts for more on the relationship between agents, context graphs, and services.

Platform Name
API Name

Context Graph

service_hierarchical_state_machine

Agent

agent

circle-info

Enterprise deployments - The Platform API also has workspace-scoped agents with richer configuration for voice and EHR workflows. See Platform API: Agents.

How Agents & Context Graphs Relate to Services

Agents and context graphs are the building blocks of services. A service combines:

  • An Agent (persona, identity, behaviors, communication style)

  • A Context Graph (state machine defining the conversational flow)

  • Version Sets that pin specific versions of each for deployment

spinner

Both agents and context graphs are versioned. You create the resource first, then create versions of it. Services reference specific versions through version sets.

Agent Management

Create an Agent

Create a new agent definition for the organization. This creates the agent container; you must then create at least one version before the agent can be used in a service.

Permission required: Organization:CreateAgent

Create an agent

post
/v1/{organization}/organization/agent

Create a new agent for the given organization. No default version for the agent will be created, so one must later to create a version for this agent so it can be used in a service.

Permissions

This endpoint requires the following permissions:

  • Organization:CreateAgent for the new agent.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
organizationstringRequired
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Body
agent_namestring · min: 1 · max: 256Required

The name of the new agent.

Responses
post
/v1/{organization}/organization/agent

List Agents

Retrieve agents for the organization. Supports filtering by deprecation status and ID.

Permission required: Organization:GetAgent (only agents the caller has permission for are returned)

Query parameters:

  • deprecated - filter by deprecation status

  • id - filter by specific agent IDs (repeatable)

  • limit - results per page (integer)

  • continuation_token - pagination token (integer)

Get agents for an organization

get
/v1/{organization}/organization/agent

Return a list of agents for the organization.

Permissions

This endpoint may be impacted by the following permissions:

  • Only agents that the authenticated user has the Organization:GetAgent permission on will be returned.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
organizationstringRequired
Query parameters
deprecatedany ofOptional

Whether the agent is deprecated.

booleanOptional
or
nullOptional
idstring[]Optional

The IDs of the agents to filter for.

Default: []
limitinteger · max: 20Optional

The maximum number of agents to return.

Default: 10
continuation_tokenintegerOptional

The continuation token from the previous request used to retrieve the next page of agents.

Default: 0
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Responses
chevron-right
200

Succeeded.

application/json
has_morebooleanRequired

Whether there are more agents to retrieve.

continuation_tokenany ofRequired

A token to supply to the next request to retrieve the next page of agents. Only populated if has_more is True.

integerOptional
or
nullOptional
get
/v1/{organization}/organization/agent

Create an Agent Version

Create a new version of an agent. For the first version, all fields must be provided. For subsequent versions, only supply the fields you want to change; other fields carry forward from the previous latest version.

Permission required: Organization:CreateAgentVersion

Fields that can be set per version:

Field
Description

initials

The agent's display initials

identity

Information about the agent's identity

background

A description of the agent's background

behaviors

Behavioral guidelines the agent follows

communication_patterns

Descriptions of the agent's communication style

voice_config

Cartesia voice configuration (set to null to leave unchanged)

circle-info

Version Query Parameter Pass version as a query parameter to specify a base version to diff against. If omitted, the latest version is used as the base.

Create an agent version

post
/v1/{organization}/organization/agent/{agent_id}/

Create a new version of the given agent. If there's no existing versions, all fields in the request must be filled and they will be used to create the initial version of the agent. Otherwise, only fill the fields that need to be updated, and the new version will retain other fields from the previous latest version.

Permissions

This endpoint requires the following permissions:

  • Organization:CreateAgentVersion for the new version of the agent.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
agent_idstringRequired

The ID of the agent to create a new version for.

Pattern: ^[a-f0-9]{24}$
organizationstringRequired
Query parameters
versionany ofOptional

The version number of the new agent version. If specified, this endpoint throws an error if the next version of the agent in the database doesn't equal to the value of this parameter.

integerOptional
or
nullOptional
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Body
initialsany ofOptional

The agent's initials.

string · min: 1 · max: 3Optional
or
nullOptional
identityany ofOptional

Information about the agent's identity.

or
nullOptional
backgroundany ofOptional

A description of the agent's background.

string · min: 1Optional
or
nullOptional
behaviorsany ofOptional

A list of behavioral guidelines that this agent follows.

string[]Optional
or
nullOptional
communication_patternsany ofOptional

A list of descriptions that illustrate the communication styles of this agent.

string[]Optional
or
nullOptional
voice_configany ofOptional

The Cartesia voice config for the agent. If set to null, it is not updated.

or
nullOptional
Responses
post
/v1/{organization}/organization/agent/{agent_id}/

Delete an Agent

Mark an agent as deprecated. The agent and its versions are not physically deleted, but new services cannot use this agent and inactive services cannot be activated with it.

circle-exclamation

Permission required: Organization:DeleteAgent

Delete an agent

delete
/v1/{organization}/organization/agent/{agent_id}/

Delete the specified agent from the organization. In practice, this endpoint marks the agent as deprecated, but will not delete this agent nor any of its versions. It does prevent new services (or inactive services to be activated) from using this agent.

An error will be raised if this endpoint is called when an active service still utilizes this agent. However, any ongoing conversation using this agent will continue to work.

Permissions:

  • Organization:DeleteAgent for the agent to delete.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
agent_idstringRequired

The ID of the agent to delete

Pattern: ^[a-f0-9]{24}$
organizationstringRequired
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Responses
chevron-right
200

Succeeded.

application/json
anyOptional
delete
/v1/{organization}/organization/agent/{agent_id}/

No content

Get Agent Versions

Retrieve the version history of an agent.

Permission required: Organization:GetAgent

Query parameters:

  • version - filter by specific version number

  • limit - results per page (integer)

  • continuation_token - pagination token (integer)

  • sort_by - sort order (repeatable)

Get agent versions

get
/v1/{organization}/organization/agent/{agent_id}/version

Retrieve the versions of an agent.

Permissions

This endpoint requires the following permissions:

  • Organization:GetAgent for the agent to retrieve.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
agent_idstringRequired

The ID of the agent.

Pattern: ^[a-f0-9]{24}$
organizationstringRequired
Query parameters
versionany ofOptional

The versions of the agent to retrieve. One can specify an exact version to retrieve, which is either the version number or latest, which retrieves the latest version. Alternatively, one can specify a range of inclusive lower and upper bound for the version number separated by -, and every version within the range would be retrieved.

Example: 1
stringOptional
or
nullOptional
limitinteger · max: 10Optional

The maximum number of agent versions to return.

Default: 10
continuation_tokenintegerOptional

The continuation token from the previous request used to retrieve the next page of agent version.

Default: 0
sort_bystring[]Optional

The fields to sort the versions by. Supported fields are version. Specify a + before the field name to indicate ascending sorting and - for descending sorting. Multiple fields can be specified to break ties.

Default: []
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Responses
chevron-right
200

Succeeded.

application/json
has_morebooleanRequired

Whether there are more agent versions to retrieve.

continuation_tokenany ofRequired

A token to supply to the next request to retrieve the next page of agent versions. Only populated if has_more is True.

integerOptional
or
nullOptional
get
/v1/{organization}/organization/agent/{agent_id}/version

Context Graph Management

circle-info

API Field Name Context Graphs are called service_hierarchical_state_machine in the API. All endpoint paths and request/response fields use this name.

Create a Context Graph

Create a new context graph for the organization. This creates the container; you must then create at least one version before it can be used in a service.

Permission required: Organization:CreateServiceHierarchicalStateMachine

Create a service hierarchical state machine

post
/v1/{organization}/organization/service_hierarchical_state_machine

Create a new state machine for the given organization. No default version for the state machine will be created, so one must later create a version for this state machine so it can be used in a service.

Permissions

This endpoint requires the following permissions:

  • Organization:CreateServiceHierarchicalStateMachine for the new service hierarchical state machine.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
organizationstringRequired
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Body
state_machine_namestring · min: 1 · max: 256Required

The name of the new state machine.

Responses
post
/v1/{organization}/organization/service_hierarchical_state_machine

List Context Graphs

Retrieve context graphs for the organization. Supports filtering by deprecation status and ID.

Permission required: Organization:GetServiceHierarchicalStateMachine (only context graphs the caller has permission for are returned)

Query parameters:

  • deprecated - filter by deprecation status

  • id - filter by specific IDs (repeatable)

  • limit - results per page (integer)

  • continuation_token - pagination token (integer)

Get service hierarchical state machines for an organization

get
/v1/{organization}/organization/service_hierarchical_state_machine

Return a list of service hierarchical state machines for the organization.

Permissions

This endpoint may be impacted by the following permissions:

  • Only state machines that the authenticated user has the Organization:GetServiceHierarchicalStateMachine permission on will be returned.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
organizationstringRequired
Query parameters
deprecatedany ofOptional

Whether the state machine is deprecated.

booleanOptional
or
nullOptional
idstring[]Optional

The IDs of the state machines to filter for.

Default: []
limitinteger · max: 50Optional

The maximum number of service hierarchical state machines to return.

Default: 50
continuation_tokenintegerOptional

The continuation token from the previous request used to retrieve the next page of state machines.

Default: 0
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Responses
chevron-right
200

Succeeded.

application/json
has_morebooleanRequired

Whether there are more state machines to fetch.

continuation_tokenany ofRequired

A token to supply to the next request to retrieve the next page of state machines. Only populated if has_more is True.

integerOptional
or
nullOptional
get
/v1/{organization}/organization/service_hierarchical_state_machine

Create a Context Graph Version

Create a new version of a context graph. The version defines the full state machine including states, transitions, initial states, terminal states, and behavioral guidelines.

Permission required: Organization:CreateServiceHierarchicalStateMachineVersion

The version must satisfy these constraints:

  • Each action state must have at least one action

  • Exit condition next_state values must reference existing states (not the current state), or reference external state machines

  • Required fields include description, states, new_user_initial_state, returning_user_initial_state, terminal_state, references, and global guidelines

Field
Description

description

A description of this context graph version

states

The internal states in the context graph

new_user_initial_state

The starting state for new users (must be an action state)

returning_user_initial_state

The starting state for returning users (must be an action state)

terminal_state

The state when a session ends (must be an action state)

references

Dictionary of external context graphs this one references

global_intra_state_navigation_guidelines

Guidelines for navigating between subgoals and exit conditions

global_action_guidelines

Guidelines for agent behavior when engaging with users

global_boundary_constraints

Guidelines for what the agent should not do

circle-info

Dry Run Pass dry_run=true as a query parameter to validate the version without creating it.

Create a service hierarchical state machine version

post
/v1/{organization}/organization/service_hierarchical_state_machine/{service_hierarchical_state_machine_id}/

Create a new version for the given service hierarchical state machine. The new version will be created with the supplied data. It needs to satisfy the following constraints:

  • Each action state must have at least one action.
  • For action and decision states, each exit condition's next_state must either be a string that exists in the states and cannot be the same as the current state, or a 2-tuple of strings, with the first string of the form {external_service_hierarchical_state_machine_reference.external_state_name}, and the second string the jumpback state which must be a state in the states.
  • For recall, reflection, and tool_call states, next_state must either be a string that exists in the states and cannot be the same as the current state, or a 2-tuple of strings, with the first string of the form {external_service_hierarchical_state_machine_reference.external_state_name}, and the second string the jumpback state which must be a state in the states.
  • The terminal state cannot have exit conditions and must have exactly one action.

See the per-request-field documentation for more field-specific constraints.

Due to the complexity of the state machine data structure, this endpoint provides a dry_run parameter. If set to True, the endpoint will check the supplied state machine would pass validations, but does not actually create a new version. In this case, the endpoint returns an empty response with a 201 status code.

Permissions:

This endpoint requires the following permissions:

  • Organization:CreateServiceHierarchicalStateMachineVersion for the service hierarchical state machine.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
service_hierarchical_state_machine_idstringRequired

The ID of the service hierarchical state machine to create a new version for.

Pattern: ^[a-f0-9]{24}$
organizationstringRequired
Query parameters
versionany ofOptional

The version number of the new state machine version. If specified, this endpoint throws an error if the next version of the state machine in the database doesn't equal to the value of this parameter.

integerOptional
or
nullOptional
dry_runbooleanOptional

Whether to perform a dry run of the operation.

Default: false
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Body
descriptionstring · min: 1Required

A description of the service hierarchical state machine.

new_user_initial_statestringRequired

The state a new user will be in when a session starts. This must be an action state, and must be an internal state.

Pattern: ^[A-Za-z0-9_]+$
returning_user_initial_statestringRequired

The state a returning user will be in when a session starts. This must be an action state, and must be an internal state.

Pattern: ^[A-Za-z0-9_]+$
terminal_statestringRequired

The state the user will be in when the session ends. This must be an action state, and must be an internal state.

Pattern: ^[A-Za-z0-9_]+$
global_intra_state_navigation_guidelinesstring[]Required

A list of guidelines for how the agent will navigate between subgoals and exit conditions within this state. This is injected into the intra_state_navigation_guidelines field of every action state.

global_action_guidelinesstring[]Required

A list of guidelines for how the agent will behave when engaging with user. This is injected into the action_guidelines field of every action state.

global_boundary_constraintsstring[]Required

A list of guidelines for how the agent will not behave when engaging with user. This is injected into the boundary_constraints field of every action state.

Responses
post
/v1/{organization}/organization/service_hierarchical_state_machine/{service_hierarchical_state_machine_id}/

Delete a Context Graph

Mark a context graph as deprecated. The context graph and its versions are not physically deleted, but new services cannot use it and inactive services cannot be activated with it.

circle-exclamation

Permission required: Organization:DeleteServiceHierarchicalStateMachine

Delete a service hierarchical state machine

delete
/v1/{organization}/organization/service_hierarchical_state_machine/{state_machine_id}/

Delete the specified state machine from the organization. In practice, this endpoint marks the state machine as deprecated, but will not delete this state machine nor any of its versions. It does prevent new services (or inactive services to be activated) from using this state machine.

An error will be raised if this endpoint is called when an active service still utilizes this state machine. However, any ongoing conversation using this state machine, as well as any state machine version that depends on this state machine will continue to work.

Permissions:

  • Organization:DeleteServiceHierarchicalStateMachine for the state machine to delete.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
state_machine_idstringRequired

The ID of the state machine to delete

Pattern: ^[a-f0-9]{24}$
organizationstringRequired
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Responses
chevron-right
200

Succeeded.

application/json
anyOptional
delete
/v1/{organization}/organization/service_hierarchical_state_machine/{state_machine_id}/

No content

Get Context Graph Versions

Retrieve the version history of a context graph.

Permission required: Organization:GetServiceHierarchicalStateMachine

Query parameters:

  • version - filter by specific version number

  • limit - results per page (integer)

  • continuation_token - pagination token (integer)

  • sort_by - sort order (repeatable)

Get service hierarchical state machine versions

get
/v1/{organization}/organization/service_hierarchical_state_machine/{service_hierarchical_state_machine_id}/version

Retrieve the versions of a state machine.

Permissions

This endpoint requires the following permissions:

  • Organization:GetServiceHierarchicalStateMachine for the state machine to retrieve.
Authorizations
AuthorizationstringRequired

The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.

AuthorizationstringRequired

Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the SignInWithAPIKey endpoint.

X-ORG-IDstringRequired

An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.

Path parameters
service_hierarchical_state_machine_idstringRequired

The ID of the state machine.

Pattern: ^[a-f0-9]{24}$
organizationstringRequired
Query parameters
versionany ofOptional

The versions of the state machine to retrieve. One can specify an exact version to retrieve, which is either the version number or latest, which retrieves the latest version. Alternatively, one can specify a range of inclusive lower and upper bound for the version number separated by -, and every version within the range would be retrieved.

Example: 1
stringOptional
or
nullOptional
limitinteger · max: 10Optional

The maximum number of state machine versions to return.

Default: 10
continuation_tokenintegerOptional

The continuation token from the previous request used to retrieve the next page of state machine versions.

Default: 0
sort_bystring[]Optional

The fields to sort the versions by. Supported fields are version. Specify a + before the field name to indicate ascending sorting and - for descending sorting. Multiple fields can be specified to break ties.

Default: []
Header parameters
x-mongo-cluster-nameany ofOptional

The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.

stringOptional
or
nullOptional
Sec-WebSocket-Protocolstring[]OptionalDefault: []
Responses
chevron-right
200

Succeeded.

application/json
has_morebooleanRequired

Whether there are more state machine versions to retrieve.

continuation_tokenany ofRequired

A token to supply to the next request to retrieve the next page of state machine versions. Only populated if has_more is True.

integerOptional
or
nullOptional
get
/v1/{organization}/organization/service_hierarchical_state_machine/{service_hierarchical_state_machine_id}/version

Typical Workflow

spinner
  1. Create the agent and context graph containers

  2. Create initial versions of each with full configuration

  3. Create a service referencing the agent and context graph

  4. Configure version sets (release, staging, dev) to pin specific versions

  5. Iterate by creating new versions and updating version sets

Last updated

Was this helpful?