Command API
Enable external systems to programmatically initiate access requests, enabling automation and integration with internal tools, bots, and security workflows.
The Command API enables programmatic creation of access requests within the P0 platform. It is designed to support custom workflows and automation. Integrate with external systems and services to initiate access grants without using the P0 user interface.
This is particularly useful for integrating P0 into your internal tooling, bots, or security workflows that require automatic access escalation based on alerts, CI/CD pipelines, or external approvals.
Runs a P0 command for the authenticated identity. The request runs through your organization's access policies, guardrails, and audit trail exactly as a request made in the P0 dashboard or CLI does.
The P0 organization slug, the same value that appears in console URLs at p0.app/o/{orgId}.
The command arguments, matching the p0 request CLI command with the leading p0 removed. Each flag and its value are separate array elements, for example ["request", "aws", "role", "MyReadOnlyRole", "--account", "123456789012", "--reason", "..."].
The client name to record for the invocation. Use p0.
p0When true, the response streams newline-delimited JSON status updates over the open connection until the request is approved, denied, or errors, instead of returning once the request is created. For one-shot status checks in automation, prefer polling GET /o/{orgId}/permission-requests/{requestId} from the Access Requests API.
The command ran. For request commands the body confirms the created access request and returns its ID.
trueThe ID of the created access request. Use it with the Access Requests API to check status, approve, deny, or revoke.
A human-readable confirmation, including a link to the request details page.
Whether an equivalent request or grant already existed.
The created access request document.
The request body is invalid, for example argv is missing or is not an array of strings.
The caller could not be authenticated.
The command did not complete before the server's timeout.
POST /o/{orgId}/command HTTP/1.1
Host: api.p0.app
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 47
{
"argv": [
"text"
],
"scriptName": "p0",
"wait": true
}{
"ok": true,
"id": "text",
"message": "text",
"isPreexisting": true,
"request": {}
}Last updated