> ## Documentation Index
> Fetch the complete documentation index at: https://docs.needalert.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Preview an alert

> What sending this item's alert right now would cost: eligible subscribers, credits (one per person), the chain's balance and whether it covers the send. Nothing is sent or charged. `schedule` gives the window `scheduled_at` accepts and the lead of the low-balance warning.



## OpenAPI

````yaml /api-reference/openapi.json get /establishments/{establishment}/items/{item}/dispatch-preview
openapi: 3.1.0
info:
  title: Need Alert API
  version: '1'
  description: >-
    The Need Alert API lets your own system — an ERP, an online store, a
    clinic's scheduling software — do what the panel does, without anyone at the
    screen: keep items in sync, read who is waiting, estimate the cost of an
    alert, send or schedule it, and follow your credit balance.


    Authenticate every request with an API key created by the chain owner in the
    panel (**Integrações**), sent as `Authorization: Bearer <key>`. Always send
    `Accept: application/json`. Send `Idempotency-Key` on the two creating
    endpoints so a retry never creates an item or alerts the subscribers twice.


    Guides, in Portuguese and English:
    https://need-alert.mintlify.app/api/overview
servers:
  - url: https://needalert.app/api/v1
    description: Production
security:
  - apiKey: []
tags:
  - name: Establishments
  - name: Items
  - name: Dispatches
  - name: Credits
paths:
  /establishments/{establishment}/items/{item}/dispatch-preview:
    get:
      tags:
        - Dispatches
      summary: Preview an alert
      description: >-
        What sending this item's alert right now would cost: eligible
        subscribers, credits (one per person), the chain's balance and whether
        it covers the send. Nothing is sent or charged. `schedule` gives the
        window `scheduled_at` accepts and the lead of the low-balance warning.
      operationId: v1.establishments.items.dispatch-preview
      parameters:
        - name: establishment
          in: path
          required: true
          description: The establishment ID
          schema:
            type: integer
        - name: item
          in: path
          required: true
          description: The item ID
          schema:
            type: integer
        - name: Accept-Language
          in: header
          description: >-
            Language of `message` and of translated content such as item names
            (`pt-BR` or `en`). Without it, the chain's default language.
          schema:
            type: string
            enum:
              - pt-BR
              - en
          example: pt-BR
        - name: X-Request-Id
          in: header
          description: >-
            Your own correlation id (1–64 characters of `A-Za-z0-9._-`), echoed
            back; generated when absent. Quote it to support.
          schema:
            type: string
            pattern: ^[A-Za-z0-9._-]{1,64}$
            minLength: 1
            maxLength: 64
      responses:
        '200':
          description: '`DispatchPreview`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DispatchPreview'
                required:
                  - data
          headers:
            Content-Language:
              description: The language of the body, BCP 47 (`pt-BR`, `en`).
              schema:
                type: string
            X-Request-Id:
              description: The request id, yours or the one generated here.
              schema:
                type: string
        '401':
          description: '- `unauthenticated`: Missing, malformed, expired or revoked API key.'
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ErrorEnvelope'
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - unauthenticated
          headers:
            Content-Language:
              description: The language of the body, BCP 47 (`pt-BR`, `en`).
              schema:
                type: string
            X-Request-Id:
              description: The request id, yours or the one generated here.
              schema:
                type: string
        '403':
          description: >-
            - `establishment_unavailable`: The unit is inactive or suspended.

            - `forbidden`: The key lacks the permission this operation needs in
            this unit (`view`, `create_items`, `edit_items`, `dispatch_events`
            or `manage_billing`).

            - `tenant_suspended`: The chain that owns the key is suspended.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ErrorEnvelope'
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - establishment_unavailable
                          - forbidden
                          - tenant_suspended
          headers:
            Content-Language:
              description: The language of the body, BCP 47 (`pt-BR`, `en`).
              schema:
                type: string
            X-Request-Id:
              description: The request id, yours or the one generated here.
              schema:
                type: string
        '404':
          description: >-
            - `not_found`: No such resource, or it is outside the key's scope.
            The API never reveals whether a resource you cannot see exists.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ErrorEnvelope'
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - not_found
          headers:
            Content-Language:
              description: The language of the body, BCP 47 (`pt-BR`, `en`).
              schema:
                type: string
            X-Request-Id:
              description: The request id, yours or the one generated here.
              schema:
                type: string
        '429':
          description: >-
            - `too_many_requests`: Over the key's budget of 300 requests per
            minute. Wait the seconds in `Retry-After`.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ErrorEnvelope'
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - too_many_requests
          headers:
            Retry-After:
              description: Seconds to wait before the next request.
              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-Language:
              description: The language of the body, BCP 47 (`pt-BR`, `en`).
              schema:
                type: string
            X-Request-Id:
              description: The request id, yours or the one generated here.
              schema:
                type: string
components:
  schemas:
    DispatchPreview:
      type: object
      properties:
        recipients_count:
          type: integer
          description: Subscribers eligible right now.
        credits_cost:
          type: integer
          description: 'Credits the send would debit: one per recipient.'
        current_balance:
          type: integer
        sufficient:
          type: boolean
          description: Whether `current_balance` covers `credits_cost`.
        schedule:
          type: object
          description: >-
            The window `scheduled_at` accepts (minutes ahead at least, days
            ahead at most) and the lead, in minutes, of the low-balance warning.
          properties:
            min_lead_minutes:
              type: integer
            max_lead_days:
              type: integer
            warning_lead_minutes:
              type: integer
          required:
            - min_lead_minutes
            - max_lead_days
            - warning_lead_minutes
      required:
        - recipients_count
        - credits_cost
        - current_balance
        - sufficient
        - schedule
      title: DispatchPreview
    ErrorEnvelope:
      type: object
      description: The shape of every error response of the API.
      properties:
        message:
          type: string
          description: >-
            Translated (see `Content-Language`), for display only. Never program
            against it.
        code:
          type: string
          description: Stable `snake_case` identifier of the error. Program against it.
        errors:
          type: object
          description: >-
            Only on some errors: the invalid fields of a `validation_failed`, or
            extra data of a business-rule refusal.
      required:
        - message
        - code
      title: ErrorEnvelope
  securitySchemes:
    apiKey:
      type: http
      description: >-
        An API key created by the chain owner in the panel (**Integrações** →
        **Nova chave**), sent as `Authorization: Bearer <key>`. The key
        (`<id>|na_…`) is shown once, at creation; rotate or revoke it on the
        same screen. It is a server secret: never ship it in browser or mobile
        code.
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.