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.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreateAgentTaskResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
CreateAgentTaskResponse res = sdk.agentTasks().create()
.call();
if (res.agentTask().isPresent()) {
System.out.println(res.agentTask().get());
}
}
}
CreateAgentTaskResponse
| Error Type |
Status Code |
Content Type |
| models/errors/ClerkErrors |
400, 404, 422 |
application/json |
| models/errors/SDKError |
4XX, 5XX |
*/* |
Revokes a pending agent task.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.RevokeAgentTaskResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
.build();
RevokeAgentTaskResponse res = sdk.agentTasks().revoke()
.agentTaskId("<id>")
.call();
if (res.agentTask().isPresent()) {
System.out.println(res.agentTask().get());
}
}
}
| Parameter |
Type |
Required |
Description |
agentTaskId |
String |
✔️ |
The ID of the agent task to be revoked. |
RevokeAgentTaskResponse
| Error Type |
Status Code |
Content Type |
| models/errors/ClerkErrors |
400, 404 |
application/json |
| models/errors/SDKError |
4XX, 5XX |
*/* |