# 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"}}}}}}
```
