# ForLoop Notify integration guide Send app-scoped email, manage reusable templates, and observe delivery, suppression, and billing state. - Base URL: `https://notify.app.forloop.cc` - Console: `https://notify.app.forloop.cc/console` - Contract version: `1.0.1` - Supported versions: `1.0.0, 1.0.1` - Machine-readable guide: `https://notify.app.forloop.cc/llms.txt` ## Quickstart Create an app-subject connection to this service, then exchange the app credential for an assertion. ```bash curl -X POST https://notify.app.forloop.cc/api/opencode/a2a/connections//assertion \ -H "x-api-token: $FLC_APP_CREDENTIAL" \ -H "content-type: application/json" \ -d '{"scopes":["notify.messages:write"],"contractVersion":"1.0.1"}' ``` The assertion is valid for **300 seconds**. Send it as `Authorization: Bearer ` on every `/v1` call. 1. Create a template with POST /v1/templates, or send inline content. 2. Send a notification to a bare email address. 3. Poll GET /v1/notifications/{id} until accepted or terminal failure. 4. Read GET /v1/usage to confirm the provider-accepted charge. ## Authentication and tenancy The service trusts only a verified app assertion. It checks `iss`, `aud`, `sub=app:`, `appPublicId`, `env`, scopes, and the pinned `contractVersion`. - The payer is always `APP:` from the assertion; never accept a payer or app ID from the request body. - Resources are scoped to `(appPublicId, env)`. A foreign resource returns `404`, not `403`. - Writes require `Idempotency-Key`. Reuse the same key only for the same logical request. - Reuse the same assertion for a short logical workflow, but exchange a fresh one for a new workflow; do not cache it indefinitely. ## Scopes - `notify.messages:read` - `notify.messages:write` - `notify.templates:read` - `notify.templates:write` ## API reference | Method | Path | Access | Success | Tool | Purpose | | --- | --- | --- | --- | --- | --- | | `POST` | `/v1/notifications` | write | 202 | Send notification | Send one email to one recipient, either from an app-scoped template plus templateData or from inline subject/html/text. Optional base64 attachments (for example an ICS reminder) are supported. Returns 202 with a stable notificationId. Requires an Idempotency-Key header. | | `GET` | `/v1/notifications/{id}` | read | 200 | Get notification | Read one notification by id, including status, attempts, provider message id, and billing state. Rendered content and the full recipient are only returned with include=content. | | `GET` | `/v1/notifications` | read | 200 | List notifications | List the caller app's notifications for the environment, newest first, with optional status filtering and cursor pagination. | | `POST` | `/v1/notifications/{id}/cancel` | write | 202 | Cancel notification | Cancel a queued notification before dispatch and release its billing reservation. Accepted or failed notifications cannot be canceled. Requires an Idempotency-Key header. | | `POST` | `/v1/templates` | write | 201 | Create template | Create an app-scoped email template with a subject, optional HTML/text bodies, and {{variable}} placeholders. Requires an Idempotency-Key header. | | `GET` | `/v1/templates/{id}` | read | 200 | Get template | Read one app-scoped template, including its content and version. | | `GET` | `/v1/templates` | read | 200 | List templates | List the caller app's templates for the environment, newest first, with cursor pagination. | | `PATCH` | `/v1/templates/{id}` | write | 200 | Update template | Partially update a template's name, description, subject, html, or text using its current version for optimistic concurrency. Requires an Idempotency-Key header. | | `DELETE` | `/v1/templates/{id}` | write | 204 | Delete template | Delete a template permanently. Already-queued notifications keep their frozen rendered content. Requires an Idempotency-Key header. | ### Send notification `POST /v1/notifications` · write · success 202 Send one email to one recipient, either from an app-scoped template plus templateData or from inline subject/html/text. Optional base64 attachments (for example an ICS reminder) are supported. Returns 202 with a stable notificationId. Requires an Idempotency-Key header. **Example** ```http POST /v1/notifications Idempotency-Key: invoice-123-ready Authorization: Bearer {"channel":"email","to":"client@example.com","templateId":"tpl_abc123","templateData":{"name":"Ada","invoiceUrl":"https://app.example.com/invoices/123"}} 202 {"notification":{"notificationId":"ntf_123","status":"queued","channel":"email","toMasked":"c***@example.com","subject":"Invoice 123 is ready","billing":{"state":"reserved","quotedAmountFLC":10}}} ``` **Output fields:** notification ### Get notification `GET /v1/notifications/{id}` · read · success 200 Read one notification by id, including status, attempts, provider message id, and billing state. Rendered content and the full recipient are only returned with include=content. **Example** ```http GET /v1/notifications/ntf_123?include=content Authorization: Bearer 200 {"notification":{"notificationId":"ntf_123","status":"accepted","providerMessageId":"","billing":{"state":"charged","quotedAmountFLC":10}}} ``` **Output fields:** notification ### List notifications `GET /v1/notifications` · read · success 200 List the caller app's notifications for the environment, newest first, with optional status filtering and cursor pagination. **Example** ```http GET /v1/notifications?status=accepted&limit=50 Authorization: Bearer 200 {"notifications":[{"notificationId":"ntf_123","status":"accepted","toMasked":"c***@example.com"}],"nextCursor":"eyJwayI6..."} ``` **Output fields:** notifications, nextCursor ### Cancel notification `POST /v1/notifications/{id}/cancel` · write · success 202 Cancel a queued notification before dispatch and release its billing reservation. Accepted or failed notifications cannot be canceled. Requires an Idempotency-Key header. **Example** ```http POST /v1/notifications/ntf_123/cancel Idempotency-Key: cancel-ntf-123 Authorization: Bearer 202 {"notification":{"notificationId":"ntf_123","status":"canceled"}} ``` **Output fields:** notification ### Create template `POST /v1/templates` · write · success 201 Create an app-scoped email template with a subject, optional HTML/text bodies, and {{variable}} placeholders. Requires an Idempotency-Key header. **Example** ```http POST /v1/templates Idempotency-Key: template-invoice-ready Authorization: Bearer {"name":"invoice-ready","subject":"Invoice {{number}} is ready","html":"

Hi {{name}},

","text":"Hi {{name}},"} 201 {"template":{"templateId":"tpl_123","version":1}} ``` **Output fields:** template ### Get template `GET /v1/templates/{id}` · read · success 200 Read one app-scoped template, including its content and version. **Example** ```http GET /v1/templates/tpl_123 Authorization: Bearer 200 {"template":{"templateId":"tpl_123","name":"invoice-ready","subject":"Invoice {{number}} is ready","version":1}} ``` **Output fields:** template ### List templates `GET /v1/templates` · read · success 200 List the caller app's templates for the environment, newest first, with cursor pagination. **Example** ```http GET /v1/templates?limit=50 Authorization: Bearer 200 {"templates":[{"templateId":"tpl_123","name":"invoice-ready","version":1}],"nextCursor":"eyJwayI6..."} ``` **Output fields:** templates, nextCursor ### Update template `PATCH /v1/templates/{id}` · write · success 200 Partially update a template's name, description, subject, html, or text using its current version for optimistic concurrency. Requires an Idempotency-Key header. **Example** ```http PATCH /v1/templates/tpl_123 Idempotency-Key: template-invoice-ready-v2 Authorization: Bearer {"version":1,"subject":"Your invoice {{number}} is ready"} 200 {"template":{"templateId":"tpl_123","version":2}} ``` **Output fields:** template ### Delete template `DELETE /v1/templates/{id}` · write · success 204 Delete a template permanently. Already-queued notifications keep their frozen rendered content. Requires an Idempotency-Key header. **Example** ```http DELETE /v1/templates/tpl_123 Idempotency-Key: delete-template-tpl-123 Authorization: Bearer 204 (empty body) ``` **Output fields:** ## Errors and retries | Code | Meaning | Retry? | | --- | --- | --- | | `invalid_assertion` / `expired` | The assertion is missing, invalid, or expired. | No; exchange a fresh assertion. | | `insufficient_scope` | The assertion does not carry a required scope. | No; update the connection grant. | | `env_mismatch` / `audience_mismatch` | Wrong platform environment or target. | No; fix the connection. | | `invalid_request` | The request body or parameters are invalid. | No. | | `not_found` | The resource is absent or belongs to another app. | No. | | `conflict` | Version, state, or idempotency conflict. | No; read the current state first. | | `quota_exceeded` / `rate_limited` | Per-app quota or rate limit reached. | Yes, after the indicated delay. | | `internal_error` / `provider_transport` | Transient platform or provider failure. | Yes, with backoff and the same idempotency key. | ## Billing 10 FLC per 1 message (ceil). Payer: `APP:`. Failures are free. The service reserves before billable work and commits only after the success condition in its contract. A failed, filtered, or canceled unit is free. A successful unit that cannot settle is retried durably and is never silently released. ## Limits and retention - Notification history and templates are scoped to one app and environment. - Recipient, attachment, and body limits are enforced per request. - The service charges 10 FLC per provider-accepted email; failed attempts are free. - Suppressed recipients are rejected before a reservation is made. - Use the `Idempotency-Key` header for every write. ## AI-agent checklist 1. Discover the target agent card and pin its exact contract version. 2. Exchange the app credential for a fresh assertion immediately before the call. 3. Use the generated client types; never hand-write a response type. 4. Send `Idempotency-Key` on every write and reuse it only for the same logical request. 5. Never infer the payer or app ID from a request body; use the verified assertion. 6. Treat 4xx errors as terminal unless the contract explicitly says otherwise; retry only transient 5xx/transport errors with backoff. 7. Read the returned job/delivery state before presenting success to a user. - Never put a notification ID or payer in caller metadata or a request body. - A 2xx from the provider is the charge point; queued, sending, failed, and canceled sends are not charged. - Bounce and complaint webhooks are signed and must be verified before changing suppression state.