# Custom Notifiers

Implement your own API endpoints that P0 can send notifications to.

## Set up Custom Notifier Integration

### Configuration Parameters

These parameters are configured by you during setup.

The examples use a custom notifier that sends notifications to an internal application for custom processing. Each custom notifier integration supports different trigger types. To reduce notification noise, you can choose only the specific triggers you want to be notified about.

<table><thead><tr><th width="179.36224365234375">Parameter</th><th>Description</th><th>Example Value</th></tr></thead><tbody><tr><td>Notifier ID</td><td>The identifier of the system you are integrating*</td><td>my-notifier-service</td></tr><tr><td>Notifier Name</td><td>The name of the custom notifier integration</td><td>Internal Customer Admin App</td></tr><tr><td>Webhook URL</td><td>Your https URL that P0 uses to call your endpoints.</td><td>https://p0-api.example.com/notifications</td></tr></tbody></table>

<sup>\* Identifiers in P0 do not allow whitespace and by convention use CamelCasing. Not visible to users.</sup>

## OpenAPI Specification

This specification describes the API endpoint you must implement to create a custom notifier integration in P0.

{% file src="<https://3783273641-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQNwGQz62W737pY0FzVb%2Fuploads%2Fgit-blob-2da82171eeec06dc5d65748a5dfbb67f2909525a%2Fcustom-resource-api.yml?alt=media&token=68210e62-deee-4b53-9849-87b1cc6372ce>" %}

## Receive notifications about requests and preapprovals

> This endpoint receives access-related notifications from P0, including user access requests and preapproval notifications. Implement this endpoint to handle custom notifiers that are not natively supported by P0. Once implemented, register the endpoint using a custom notifier in the P0 console to start receiving events.<br>

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"tags":[{"name":"notifications"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"P0 generates a keypair during integration setup. Each http request sent by P0 to your endpoints contains a JWT signed with the private key in the Authorization header. Your endpoints must use the public key retrieved during integration setup, to decode the JWT   and verify its claims. The claims are: sub (Subject) iss (Issuer), aud (Audience), iat (Issued At), exp (Expiry)"}},"schemas":{"NotificationEvent":{"oneOf":[{"$ref":"#/components/schemas/PreapprovalCreatedEvent"},{"$ref":"#/components/schemas/PreapprovalExpiredEvent"}],"discriminator":{"propertyName":"type"}},"PreapprovalCreatedEvent":{"required":["id","name","eventType","data"],"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of your custom notifier. The id is configured during setup of the custom notifier in P0."},"name":{"type":"string","description":"The user friendly name of your custom notifier. The name is configured during setup of the custom notifier in P0."},"eventType":{"type":"string","enum":["preapproval-created"]},"data":{"$ref":"#/components/schemas/Preapproval"}}},"Preapproval":{"type":"object","required":["id","type","access","startsAt","endsAt","principal","permission"],"properties":{"id":{"type":"string","description":"Random identifier for the preapproval generated by P0"},"type":{"type":"string","description":"The integration type the preapproval is for."},"access":{"type":"string","description":"The access type the preapproval is for."},"permission":{"$ref":"#/components/schemas/Permission"},"startsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval becomes active."},"endsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval expires."},"createdAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval was created."},"principal":{"type":"string","description":"The principal this preapproval grants access to"},"approver":{"$ref":"#/components/schemas/ApprovalDetails"},"reason":{"type":"string","description":"The justification for the creation of this preapproval."}}},"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}},"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}},"PreapprovalExpiredEvent":{"required":["id","name","eventType","data"],"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of your custom notifier. The id is configured during setup of the custom notifier in P0."},"name":{"type":"string","description":"The user friendly name of your custom notifier. The name is configured during setup of the custom notifier in P0."},"eventType":{"type":"string","enum":["preapproval-expired"]},"data":{"$ref":"#/components/schemas/Preapproval"}}},"Error":{"type":"object","required":["type","message"],"properties":{"type":{"type":"string","enum":["public","internal"]},"message":{"type":"string"},"errorId":{"type":"string"}}}},"responses":{"EmptySuccessResponse":{"description":"Success"},"ErrorResponse":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/":{"post":{"tags":["notifications"],"summary":"Receive notifications about requests and preapprovals","description":"This endpoint receives access-related notifications from P0, including user access requests and preapproval notifications. Implement this endpoint to handle custom notifiers that are not natively supported by P0. Once implemented, register the endpoint using a custom notifier in the P0 console to start receiving events.\n","operationId":"handleAccessEvent","requestBody":{"description":"Grant a user access to a resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotificationEvent"}}},"required":true},"responses":{"200":{"$ref":"#/components/responses/EmptySuccessResponse"},"default":{"$ref":"#/components/responses/ErrorResponse"}}}}}}
```

## The NotificationEvent object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"NotificationEvent":{"oneOf":[{"$ref":"#/components/schemas/PreapprovalCreatedEvent"},{"$ref":"#/components/schemas/PreapprovalExpiredEvent"}],"discriminator":{"propertyName":"type"}},"PreapprovalCreatedEvent":{"required":["id","name","eventType","data"],"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of your custom notifier. The id is configured during setup of the custom notifier in P0."},"name":{"type":"string","description":"The user friendly name of your custom notifier. The name is configured during setup of the custom notifier in P0."},"eventType":{"type":"string","enum":["preapproval-created"]},"data":{"$ref":"#/components/schemas/Preapproval"}}},"Preapproval":{"type":"object","required":["id","type","access","startsAt","endsAt","principal","permission"],"properties":{"id":{"type":"string","description":"Random identifier for the preapproval generated by P0"},"type":{"type":"string","description":"The integration type the preapproval is for."},"access":{"type":"string","description":"The access type the preapproval is for."},"permission":{"$ref":"#/components/schemas/Permission"},"startsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval becomes active."},"endsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval expires."},"createdAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval was created."},"principal":{"type":"string","description":"The principal this preapproval grants access to"},"approver":{"$ref":"#/components/schemas/ApprovalDetails"},"reason":{"type":"string","description":"The justification for the creation of this preapproval."}}},"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}},"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}},"PreapprovalExpiredEvent":{"required":["id","name","eventType","data"],"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of your custom notifier. The id is configured during setup of the custom notifier in P0."},"name":{"type":"string","description":"The user friendly name of your custom notifier. The name is configured during setup of the custom notifier in P0."},"eventType":{"type":"string","enum":["preapproval-expired"]},"data":{"$ref":"#/components/schemas/Preapproval"}}}}}}
```

## The PreapprovalCreatedEvent object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"PreapprovalCreatedEvent":{"required":["id","name","eventType","data"],"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of your custom notifier. The id is configured during setup of the custom notifier in P0."},"name":{"type":"string","description":"The user friendly name of your custom notifier. The name is configured during setup of the custom notifier in P0."},"eventType":{"type":"string","enum":["preapproval-created"]},"data":{"$ref":"#/components/schemas/Preapproval"}}},"Preapproval":{"type":"object","required":["id","type","access","startsAt","endsAt","principal","permission"],"properties":{"id":{"type":"string","description":"Random identifier for the preapproval generated by P0"},"type":{"type":"string","description":"The integration type the preapproval is for."},"access":{"type":"string","description":"The access type the preapproval is for."},"permission":{"$ref":"#/components/schemas/Permission"},"startsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval becomes active."},"endsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval expires."},"createdAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval was created."},"principal":{"type":"string","description":"The principal this preapproval grants access to"},"approver":{"$ref":"#/components/schemas/ApprovalDetails"},"reason":{"type":"string","description":"The justification for the creation of this preapproval."}}},"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}},"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}}}}}
```

## The PreapprovalExpiredEvent object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"PreapprovalExpiredEvent":{"required":["id","name","eventType","data"],"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of your custom notifier. The id is configured during setup of the custom notifier in P0."},"name":{"type":"string","description":"The user friendly name of your custom notifier. The name is configured during setup of the custom notifier in P0."},"eventType":{"type":"string","enum":["preapproval-expired"]},"data":{"$ref":"#/components/schemas/Preapproval"}}},"Preapproval":{"type":"object","required":["id","type","access","startsAt","endsAt","principal","permission"],"properties":{"id":{"type":"string","description":"Random identifier for the preapproval generated by P0"},"type":{"type":"string","description":"The integration type the preapproval is for."},"access":{"type":"string","description":"The access type the preapproval is for."},"permission":{"$ref":"#/components/schemas/Permission"},"startsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval becomes active."},"endsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval expires."},"createdAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval was created."},"principal":{"type":"string","description":"The principal this preapproval grants access to"},"approver":{"$ref":"#/components/schemas/ApprovalDetails"},"reason":{"type":"string","description":"The justification for the creation of this preapproval."}}},"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}},"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}}}}}
```

## The PermissionRequest object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"PermissionRequest":{"type":"object","properties":{"requestId":{"type":"string","description":"Random identifier for the request generated by P0"},"type":{"type":"string","description":"The integration type that this request was created for"},"access":{"type":"string","description":"The access type requested"},"status":{"type":"string","enum":["APPROVED","CLEANED_UP","DENIED","DONE","DRAFT","ERRORED","EXPIRED","NEW","EXPIRY_SUBMITTED","PENDING_APPROVAL","REVOKE_SUBMITTED","REVOKED","STAGED"]},"principal":{"type":"string","description":"The principal access will be granted to"},"requestor":{"type":"string","description":"The user requesting access. This payload might be different if requesting on behalf of another user."},"reason":{"type":"string","description":"The requestor's justification for this access request."},"requestedTimestamp":{"type":"number","description":"The epoch timestamp in milliseconds of when this request was created."},"permission":{"$ref":"#/components/schemas/Permission"},"approver":{"$ref":"#/components/schemas/ApprovalDetails"},"error":{"$ref":"#/components/schemas/Error"}}},"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}},"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}},"Error":{"type":"object","required":["type","message"],"properties":{"type":{"type":"string","enum":["public","internal"]},"message":{"type":"string"},"errorId":{"type":"string"}}}}}}
```

## The Preapproval object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"Preapproval":{"type":"object","required":["id","type","access","startsAt","endsAt","principal","permission"],"properties":{"id":{"type":"string","description":"Random identifier for the preapproval generated by P0"},"type":{"type":"string","description":"The integration type the preapproval is for."},"access":{"type":"string","description":"The access type the preapproval is for."},"permission":{"$ref":"#/components/schemas/Permission"},"startsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval becomes active."},"endsAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval expires."},"createdAt":{"type":"number","description":"The epoch timestamp in milliseconds for when this preapproval was created."},"principal":{"type":"string","description":"The principal this preapproval grants access to"},"approver":{"$ref":"#/components/schemas/ApprovalDetails"},"reason":{"type":"string","description":"The justification for the creation of this preapproval."}}},"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}},"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}}}}}
```

## The Permission object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"Permission":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"A short label or name for the requested permission."},"description":{"type":"string","description":"A full friendly description of the requested permission."}}}}}}
```

## The ApprovalDetails object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"ApprovalDetails":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"A unique identifier of the entity that approved the request, this may be an email."},"name":{"type":"string","description":"A user friendly name of the entity that approved the request"},"email":{"type":"string","description":"The email of the entity that approved the request."}}}}}}
```

## The Error object

```json
{"openapi":"3.0.4","info":{"title":"Custom Notifier API","version":"0.0.1"},"components":{"schemas":{"Error":{"type":"object","required":["type","message"],"properties":{"type":{"type":"string","enum":["public","internal"]},"message":{"type":"string"},"errorId":{"type":"string"}}}}}}
```


---

# 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/integrations/notifier-integrations/custom-notifiers.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.
