> For the complete documentation index, see [llms.txt](https://doc.wearepatchworks.com/product-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.wearepatchworks.com/product-documentation/api-reference/alerting/alerts.md).

# Alerts

## List Alerts

> List all alerts.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Alerts"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"AlertsListResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Alert"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"},"links":{"$ref":"#/components/schemas/PaginationLinks"}}},"Alert":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"type":{"type":"string","enum":["usage","error","token_usage"]},"config":{"type":"object"},"notification_group":{"type":"object"},"created_by":{"type":"object"},"last_triggered_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"PaginationMeta":{"type":"object","properties":{"current_page":{"type":"integer"},"from":{"type":"integer","nullable":true},"last_page":{"type":"integer"},"path":{"type":"string"},"per_page":{"type":"integer"},"to":{"type":"integer","nullable":true},"total":{"type":"integer"}}},"PaginationLinks":{"type":"object","properties":{"first":{"type":"string","format":"uri"},"last":{"type":"string","format":"uri"},"prev":{"type":"string","format":"uri","nullable":true},"next":{"type":"string","format":"uri","nullable":true}}},"MessageResponse":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/api/v1/alerts":{"get":{"summary":"List Alerts","description":"List all alerts.","parameters":[{"name":"filter[name]","in":"query","required":false,"schema":{"type":"string"},"description":"Filter results by name."},{"name":"filter[type]","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","enum":["usage","error","token_usage"]}},"description":"Filter results by type.","style":"form","explode":false},{"name":"include","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","enum":["notificationGroup","createdBy"]}},"description":"Comma-separated list of relationships to include. Available: notificationGroup, createdBy","style":"form","explode":false},{"name":"sort","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","enum":["name","-name","type","-type","created_at","-created_at","last_triggered_at","-last_triggered_at"]}},"description":"Sort field. Prefix with - for descending. Available: name, type, created_at, last_triggered_at","style":"form","explode":false},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1},"description":"Page number for pagination."},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100},"description":"Number of results per page."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsListResponse"}}}},"401":{"description":"Unauthenticated","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"429":{"description":"Too Many Requests. The rate limit for this user has been reached.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"description":"Requests allowed per minute.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in the current minute.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Alerts"],"operationId":"alertsIndex"}}}}
```

## Create Alert

> Create a new alert.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Alerts"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"AlertResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Alert"}}},"Alert":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"type":{"type":"string","enum":["usage","error","token_usage"]},"config":{"type":"object"},"notification_group":{"type":"object"},"created_by":{"type":"object"},"last_triggered_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"MessageResponse":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/api/v1/alerts":{"post":{"summary":"Create Alert","description":"Create a new alert.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertResponse"}}}},"401":{"description":"Unauthenticated","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests. The rate limit for this user has been reached.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"description":"Requests allowed per minute.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in the current minute.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Alerts"],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":255},"type":{"type":"string"},"config":{"type":"array","properties":{"threshold":{"type":"integer","minimum":1,"maximum":100},"error_event":{"type":"string"}}},"notification_group_id":{"type":"integer"}},"required":["config","name","notification_group_id","type"]}}}},"operationId":"alertsStore"}}}}
```

## Get Alert

> Get a single alert.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Alerts"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"AlertResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Alert"}}},"Alert":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"type":{"type":"string","enum":["usage","error","token_usage"]},"config":{"type":"object"},"notification_group":{"type":"object"},"created_by":{"type":"object"},"last_triggered_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"MessageResponse":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/api/v1/alerts/{alert}":{"get":{"summary":"Get Alert","description":"Get a single alert.","parameters":[{"name":"alert","in":"path","required":true,"schema":{"type":"string"},"description":"The alert identifier."},{"name":"include","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","enum":["notificationGroup","createdBy"]}},"description":"Comma-separated list of relationships to include. Available: notificationGroup, createdBy","style":"form","explode":false}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertResponse"}}}},"401":{"description":"Unauthenticated","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"404":{"description":"Not Found. The record does not exist.","content":{"application/json":{"schema":{"type":"string"}}}},"429":{"description":"Too Many Requests. The rate limit for this user has been reached.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"description":"Requests allowed per minute.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in the current minute.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Alerts"],"operationId":"alertsShow"}}}}
```

## Update Alert

> Update an existing alert.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Alerts"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"AlertResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Alert"}}},"Alert":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"type":{"type":"string","enum":["usage","error","token_usage"]},"config":{"type":"object"},"notification_group":{"type":"object"},"created_by":{"type":"object"},"last_triggered_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"MessageResponse":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/api/v1/alerts/{alert}":{"put":{"summary":"Update Alert","description":"Update an existing alert.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertResponse"}}}},"401":{"description":"Unauthenticated","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"404":{"description":"Not Found. The record does not exist.","content":{"application/json":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests. The rate limit for this user has been reached.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"description":"Requests allowed per minute.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in the current minute.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Alerts"],"parameters":[{"name":"alert","in":"path","required":true,"schema":{"type":"string"},"description":"The alert identifier."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":255},"type":{"type":"string"},"config":{"type":"array","properties":{"threshold":{"type":"integer","minimum":1,"maximum":100},"error_event":{"type":"string"}}},"notification_group_id":{"type":"integer"}}}}}},"operationId":"alertsUpdate"}}}}
```

## Delete Alert

> Delete a alert.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Alerts"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"MessageResponse":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/api/v1/alerts/{alert}":{"delete":{"summary":"Delete Alert","description":"Delete a alert.","responses":{"200":{"description":"OK"},"401":{"description":"Unauthenticated","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"404":{"description":"Not Found. The record does not exist.","content":{"application/json":{"schema":{"type":"string"}}}},"429":{"description":"Too Many Requests. The rate limit for this user has been reached.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"description":"Requests allowed per minute.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests left in the current minute.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Alerts"],"parameters":[{"name":"alert","in":"path","required":true,"schema":{"type":"string"},"description":"The alert identifier."}],"operationId":"alertsDestroy"}}}}
```
