Create an agent task on behalf of a user.
The response contains a URL that, when visited, creates a session for the user.
The agent_id is stable per agent_name within an instance. The task_id is unique per call.
import clerk_backend_api
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.agent_tasks.create(request={
"on_behalf_of": {
"user_id": "<id>",
"identifier": "<value>",
},
"permissions": clerk_backend_api.CreateAgentTaskPermissions.WILDCARD_,
"agent_name": "<value>",
"task_description": "<value>",
"redirect_url": "https://brilliant-typewriter.net",
})
# Handle response
print(res)
models.AgentTask
| Error Type |
Status Code |
Content Type |
| models.ClerkErrors |
400, 404, 422 |
application/json |
| models.SDKError |
4XX, 5XX |
*/* |
Revokes a pending agent task.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.agent_tasks.revoke(agent_task_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_task_id |
str |
✔️ |
The ID of the agent task to be revoked. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AgentTask
| Error Type |
Status Code |
Content Type |
| models.ClerkErrors |
400, 404 |
application/json |
| models.SDKError |
4XX, 5XX |
*/* |