> For the complete documentation index, see [llms.txt](https://docs.ibexa.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ibexa.ai/developers/rest-api/agents/link-sub-agent.md).

# Link Sub Agent

Link a sub-agent to a parent agent.

The sub-agent must have can\_be\_subagent=True and both agents must be in the same organisation.

Users can only link sub-agents to agents they created.

```json
{"openapi":"3.1.0","info":{"title":"Ibexa Agentic Marketing Platform","version":"0.1.0"},"security":[{"OAuth2PasswordBearer":[]}],"components":{"securitySchemes":{"OAuth2PasswordBearer":{"type":"oauth2","flows":{"password":{"scopes":{},"tokenUrl":"/api/v1/login/access-token"}}}},"schemas":{"SubAgentLinkResponseSchema":{"properties":{"sub_agent_id":{"type":"integer","title":"Sub Agent Id"},"name":{"type":"string","title":"Name"},"identifier":{"type":"string","title":"Identifier"}},"type":"object","required":["sub_agent_id","name","identifier"],"title":"SubAgentLinkResponseSchema","description":"Schema for sub-agent link response."}}},"paths":{"/api/v1/agents/{agent_id}/sub-agents/{sub_agent_id}":{"put":{"tags":["agents","public"],"summary":"Link Sub Agent","description":"Link a sub-agent to a parent agent.\n\nThe sub-agent must have can_be_subagent=True and both agents\nmust be in the same organisation.\n\nUsers can only link sub-agents to agents they created.","operationId":"agents-link_sub_agent","parameters":[{"name":"agent_id","in":"path","required":true,"schema":{"type":"integer","title":"Agent Id"}},{"name":"sub_agent_id","in":"path","required":true,"schema":{"type":"integer","title":"Sub Agent Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubAgentLinkResponseSchema"}}}},"400":{"description":"Invalid request payload or parameters","content":{"application/json":{}}},"401":{"description":"User not authenticated","content":{"application/json":{}}},"403":{"description":"User lacks permission","content":{"application/json":{}}},"404":{"description":"Resource not found or user has no permission to access it","content":{"application/json":{}}}}}}}}
```
