# Send messages and images

Submit JSON to `POST /notifications` using your application-scoped key and a stable `Idempotency-Key` header.

## A notification payload

```json
{
  "application_id": "YOUR_APPLICATION_ULID",
  "recipient_id": "YOUR_RECIPIENT_ULID",
  "title": "Backup complete",
  "body": "**Backup finished.** Open the report for details.",
  "body_format": "markdown",
  "category": "backup",
  "priority": "normal",
  "url": "https://example.com/reports/backup",
  "url_title": "View report",
  "external_id": "backup-run-unique-id",
  "ttl": 86400
}
```

Create `backup` in this application or import it from the DevOps preset, then have the recipient approve it before using this example. Only `application_id`, `recipient_id`, and `body` are required. Title defaults to the application name. Defaults: `body_format: plain`, `category: general`, `priority: normal`, `ttl: 86400` seconds. Full constraints are in [API reference](/docs/api-reference).

Categories belong to each application. Use its active, immutable category key; omitted means `general`. Rename display names without changing scripts. New categories require recipient approval. Unknown or archived keys return `422 invalid_category`; an unapproved category returns `403 recipient_not_authorized`. Priorities: `silent`, `low`, `normal`, `high`. `silent` stores an Inbox message without push. Other priorities remain subject to recipient preferences and OS settings; none guarantees bypassing Do Not Disturb. Quiet hours suppress sound rather than scheduling a send for morning.

Markdown renders safely in the Inbox. Push alerts may show text without rich formatting or images. URLs must use HTTP/HTTPS and cannot contain embedded credentials. Do not include secrets in messages or links.

## Upload one image

`POST /attachments` accepts multipart fields `application_id` and `image` with the same bearer key. JPEG, PNG, or WebP only; at most 5 MiB and 4096 by 4096 pixels. Do not manually set the multipart Content-Type boundary.

```bash
curl --fail-with-body --silent --show-error --max-time 30 \
  "$PIJON_API_BASE_URL/attachments" \
  -H "Authorization: Bearer $PIJON_API_KEY" \
  -H 'Accept: application/json' \
  -F "application_id=$PIJON_APPLICATION_ID" \
  -F 'image=@./report.png'
```

On `201`, use `data.id` as `attachment_id` in the notification JSON. Keep that ID for retries of the send; do not upload the same image on every send retry. Upload itself has no idempotency guarantee, so an ambiguous upload may leave an unclaimed duplicate.

Images stay private. Unclaimed uploads expire after 24 hours; claimed images expire 90 days after their latest use. Default sender storage is 200 MiB / 1,000 images. Script keys cannot download or delete images; the authenticated app handles those account operations. Text remains the system-alert fallback.
