# Command API

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.

## Submit a command to P0

> Submits a command to P0. This endpoint allows automation of access requests or other operations.<br>

```json
{"openapi":"3.0.3","info":{"title":"P0 Command API","version":"1.0.0"},"servers":[{"url":"https://api.p0.app"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"/o/{orgId}/command":{"post":{"summary":"Submit a command to P0","operationId":"submitCommand","description":"Submits a command to P0. This endpoint allows automation of access requests or other operations.\n","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"},"description":"Organization identifier"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["argv","scriptName"],"properties":{"argv":{"type":"array","items":{"type":"string"},"description":"Command-line arguments"},"scriptName":{"type":"string","description":"The script or command name to execute"}}}}}},"responses":{"200":{"description":"Command accepted and processed","content":{"application/json":{"schema":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean"},"message":{"type":"string"},"id":{"type":"string","description":"Request ID"},"isPreexisting":{"type":"boolean"},"isPersistent":{"type":"boolean"}}}}}},"400":{"description":"Bad request – malformed payload"},"401":{"description":"Unauthorized – missing or invalid token"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.p0.dev/access-management/just-in-time-access/just-in-time-api/command-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
