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

# Mailgun inbound email webhook

> Receives BCC'd / inbound emails from Mailgun (form-encoded multipart payload — see Mailgun's Routes/Webhooks docs for the full schema). Authenticates via the `?key=` query parameter against `MAILGUN_ROUTE_KEY`. Creates an `Activity` row, uploads any attachments to S3, detects trip-message replies, auto-associates the email with a donor by sender address when possible, and indexes the activity in Meilisearch. Documented as a webhook for reference; integrators do not call this directly.



## OpenAPI

````yaml post /activities/email-ingest
openapi: 3.0.0
info:
  title: Gratona API
  description: >-
    REST API for the Gratona fundraising platform, including donor, donation,
    sponsorship, program, event, and integration workflows. Endpoints are
    organized by tag. Most endpoints require either a Passport bearer token or
    an issued API key — see the Security Schemes section.
  contact:
    name: Gratona Engineering
    url: https://gratona.com
    email: devs@gratona.com
  version: 1.0.0
servers:
  - url: https://api.gratona.com/v1
    description: Server Version 1.0.0
security: []
tags:
  - name: Auth
    description: >-
      Login, signup, logout, password reset, and email verification for admin
      users and donors.
  - name: Donors
    description: >-
      Donor records: CRUD, profile fields, household linkage, search, filters,
      merge, and duplicate detection.
  - name: Donations
    description: >-
      Individual donation records, recurring commitments, soft credits, refunds,
      designations, and exports.
  - name: Sponsorships
    description: >-
      Donor-to-entity sponsorship relationships, lifecycle transitions, and
      sponsorship-specific filters.
  - name: Entities
    description: >-
      Recipient records (children, families, projects, animals, etc.), their
      status, and entity-level fields.
  - name: Programs
    description: >-
      Program / campaign configuration: hierarchy, settings, and program-level
      metadata.
  - name: Forms
    description: >-
      Custom form builder (HysForm), form fields, standardized donor fields, and
      field migrations.
  - name: Trips
    description: >-
      Mission-trip management: trips, participants, budgets, tasks,
      e-signatures, fundraising milestones, and background checks.
  - name: Communications
    description: >-
      Email templates, SMS, newsletters, donor email manager, and per-donor
      notes.
  - name: Payments
    description: >-
      Payment-gateway management (Stripe, PayPal, Flutterwave, QuickBooks).
      Excludes inbound webhooks — see the Webhooks tag.
  - name: Reports
    description: Dashboards, analytics, scheduled reports, and exports.
  - name: Admin
    description: >-
      Client-account administration: users, groups/permissions, settings,
      integrations, and account lifecycle.
  - name: Donor Portal
    description: >-
      Endpoints consumed by the donor-facing portal (donor login, dashboard,
      donation history, messages).
  - name: Recipient Portal
    description: Endpoints consumed by the recipient-facing portal.
  - name: Public
    description: >-
      Unauthenticated public endpoints: donor signup, public trip pages,
      peer-to-peer campaigns, public checkout.
  - name: Webhooks
    description: >-
      Inbound webhooks from third parties (Stripe, PayPal, Flutterwave, Checkr,
      DropboxSign). Annotated minimally for reference; payload shapes are owned
      by the upstream provider.
  - name: Client
    description: Client
  - name: Email Settings
    description: Email Settings
  - name: Admin Dashboard
    description: Admin Dashboard
  - name: Historical Archived Updates
    description: Historical Archived Updates
  - name: Team & access
    description: Team & access
  - name: Files
    description: Files
  - name: Wrapped
    description: Wrapped
  - name: Donor SignUp
    description: Donor SignUp
  - name: Frontend
    description: Frontend
  - name: User
    description: User
paths:
  /activities/email-ingest:
    post:
      tags:
        - Webhooks
      summary: Mailgun inbound email webhook
      description: >-
        Receives BCC'd / inbound emails from Mailgun (form-encoded multipart
        payload — see Mailgun's Routes/Webhooks docs for the full schema).
        Authenticates via the `?key=` query parameter against
        `MAILGUN_ROUTE_KEY`. Creates an `Activity` row, uploads any attachments
        to S3, detects trip-message replies, auto-associates the email with a
        donor by sender address when possible, and indexes the activity in
        Meilisearch. Documented as a webhook for reference; integrators do not
        call this directly.
      operationId: 6c71543b6c4fbed55ee021c7d9886dd8
      parameters:
        - name: key
          in: query
          description: >-
            Shared secret matching `MAILGUN_ROUTE_KEY`. Mailgun appends this
            from the route configuration.
          required: true
          schema:
            type: string
      requestBody:
        description: >-
          Mailgun's inbound multipart/form-data payload (sender, recipient,
          subject, body-plain, body-html, Message-Id, timestamp,
          message-headers, attachment-count, attachment-N, …). Refer to the
          Mailgun documentation rather than treating any single field as a
          stable contract.
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              additionalProperties: true
      responses:
        '200':
          description: Email processed.
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                  activity_id:
                    type: integer
                    format: int64
                type: object
        '400':
          description: Recipient address could not be mapped to a known client.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid `key` query parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
        '500':
          description: Processing error (S3 upload failure, DB write failure, etc.).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security: []
components:
  schemas:
    ErrorResponse:
      title: ErrorResponse
      description: >-
        Generic error envelope used by most controllers. Most error responses
        pair a human-readable `message` with `status: error`. Some endpoints
        additionally include `errors` (validator errors), `error` (legacy
        single-error string), `code`, or domain-specific context fields.
      required:
        - message
      properties:
        message:
          description: Human-readable error message.
          type: string
          example: Something went wrong. Please try again.
        status:
          description: >-
            Always the literal string `error` for failures. Some endpoints omit
            this field.
          type: string
          example: error
        error:
          description: Legacy single error code/string used by older endpoints.
          type: string
          example: invalid_request
          nullable: true
        code:
          description: >-
            Optional application-level error code (not all endpoints populate
            this).
          type: string
          example: DONOR_NOT_FOUND
          nullable: true
      type: object
    UnauthorizedResponse:
      title: UnauthorizedResponse
      description: >-
        Returned with HTTP 401 when the request lacks a valid Passport bearer
        token, a valid `X-HYS-API-Key`, or a valid session. The body is the
        simple `{message, status}` envelope emitted by `AuthenticateApiOrKey`.
      required:
        - message
        - status
      properties:
        message:
          description: >-
            Always the literal string `Unauthorized` from the `auth.api_or_key`
            middleware. Login endpoints return `Invalid Credentials` instead.
          type: string
          example: Unauthorized
        status:
          type: string
          example: error
      type: object

````

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