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

# Clawback a fraudulent/voided promotional grant (ops)

> Claw back a promotional grant when the source event that funded it is voided or refunded, or for fraud. A `LOCKED` grant claws back its full amount. A `RELEASED` grant claws back only the remaining unspent amount; any already-spent portion is recorded as a merchant loss and is **never pulled back from the customer's actual cash balance** (promotional money never converts to cash). This transitions the grant to `CLAWED_BACK` (a terminal state) in a single atomic operation. The call is mutating and idempotent on the `Idempotency-Key` header: clawing back an already-`CLAWED_BACK` grant replays as a no-op. RBAC-gated to operator/admin callers. Tenant-scoped; a grant belonging to another tenant resolves to `FORBIDDEN` (403) or `NOT_FOUND` (404).



## OpenAPI

````yaml /api-reference/openapi.yaml post /grants/{id}/clawback
openapi: 3.1.0
info:
  title: Feddi Partner API
  version: '2026-06-01'
  description: >-
    Operate a Feddi closed-loop wallet and loyalty program at the point of sale:
    identify customers, read balances, accept wallet payments, run top-ups, and
    reconcile transactions.


    All amounts are integer minor units with an explicit ISO-4217 currency.
    Balances are merchant-held and closed-loop.


    Every response uses a typed envelope (`ok` / `data` / `error` / `meta`) with
    string error codes (never a bare HTTP number) and an idempotency-replay
    flag. Authenticate with the `x-api-key` header; exchange it for a
    short-lived POS terminal JWT for hot-path calls.


    Self-validate against this document (`GET /openapi`) and read `GET
    /capabilities` for the credential types, currencies, and features enabled
    for your integration before assuming any enum.


    Operations are tagged `x-feddi-availability: ga` (stable) or `beta`
    (callable, contract may still change additively); confirm what is enabled
    for your credentials via `GET /capabilities`.


    Sandbox access is granted per partner agreement; request credentials from
    your Feddi contact.
servers:
  - url: https://api.feddi.io/v1/partner
    description: production
  - url: https://api.dev.feddi.io/v1/partner
    description: dev
security:
  - ApiKeyAuth: []
tags:
  - name: platform
    description: >-
      Platform cross-cutting: health, capabilities, openapi self-serve, merchant
      provisioning, settlement, reconciliation.
  - name: checkout_session
    description: >-
      Checkout sessions: every interaction opens a session, then identity and
      basket attach to it, and payment, top-up, and offers run against it.
  - name: auth
    description: >-
      Partner authentication + onboarding: API key lifecycle, POS terminal JWT
      exchange, terminal heartbeat.
  - name: customers
    description: >-
      Customer lookup + identification: resolve identity, cashier-panel
      summaries, preferences, GDPR export/erase.
  - name: enrollment
    description: >-
      Enrollment + signup: OTP enroll, cashback claims, identity/consent,
      customer correction + merge.
  - name: payments
    description: >-
      Payments + redemption: debit wallet (promo-first), balance-check, void,
      refund, QR mint.
  - name: topup
    description: >-
      Wallet top-up: 2-step prepare/confirm, reload-bonus grants, SKU top-up,
      settlement + reconciliation.
  - name: incentives
    description: >-
      Incentives + offers: offer feeds, apply/redeem/release locks, proposals,
      budget envelopes, points, grant clawback.
  - name: transactions
    description: >-
      Transactions + receipts: transaction detail, void, receipts, disputes,
      settlements, reconciliation, exports.
  - name: webhooks
    description: >-
      Webhooks + events: subscriptions, delivery history + retry, event catalog,
      polling fallback.
paths:
  /grants/{id}/clawback:
    post:
      tags:
        - incentives-offers
      summary: Clawback a fraudulent/voided promotional grant (ops)
      description: >-
        Claw back a promotional grant when the source event that funded it is
        voided or refunded, or for fraud. A `LOCKED` grant claws back its full
        amount. A `RELEASED` grant claws back only the remaining unspent amount;
        any already-spent portion is recorded as a merchant loss and is **never
        pulled back from the customer's actual cash balance** (promotional money
        never converts to cash). This transitions the grant to `CLAWED_BACK` (a
        terminal state) in a single atomic operation. The call is mutating and
        idempotent on the `Idempotency-Key` header: clawing back an
        already-`CLAWED_BACK` grant replays as a no-op. RBAC-gated to
        operator/admin callers. Tenant-scoped; a grant belonging to another
        tenant resolves to `FORBIDDEN` (403) or `NOT_FOUND` (404).
      operationId: clawbackGrant
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            The promotional grant ledger row id. NOT a UUID, grant ids carry the
            `pg_` prefix.
          schema:
            type: string
          example: pg_7781
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClawbackGrantRequest'
            example:
              meta:
                partner_request_id: 2b3c4d5e-6f70-8192-0314-253647586a7b
                occurred_at: '2026-06-05T11:10:00Z'
                sent_at: '2026-06-05T11:10:01Z'
                api_version: '2026-06-01'
              reason: SOURCE_ORDER_VOIDED
              note: Odoo pos.order 5512 refunded
      responses:
        '200':
          description: Grant clawed back; any spent portion logged as merchant loss.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/ClawbackResult'
              example:
                ok: true
                data:
                  grant_id: pg_7781
                  state: CLAWED_BACK
                  clawed_back:
                    amount_minor: 600
                    currency: QAR
                  spent_loss_logged:
                    amount_minor: 400
                    currency: QAR
                  clawed_at: '2026-06-05T11:10:02Z'
                error: null
                meta:
                  request_id: req_cc22dd33
                  idempotency_replayed: false
                  api_version: '2026-06-01'
                  data_completeness_score: 100
                  decision_trace_id: null
                  capabilities: {}
        '400':
          description: >-
            Grant not in a clawback-able state (already EXPIRED/CLAWED_BACK) or
            validation failure (`VALIDATION_ERROR`).
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      error:
                        $ref: '#/components/schemas/Error'
        '401':
          description: Missing/invalid API key (`INVALID_API_KEY`).
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      error:
                        $ref: '#/components/schemas/Error'
        '403':
          description: Key lacks clawback permission (`FORBIDDEN`).
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      error:
                        $ref: '#/components/schemas/Error'
        '404':
          description: Grant not found / cross-tenant (`NOT_FOUND`).
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      error:
                        $ref: '#/components/schemas/Error'
        '422':
          description: '`IDEMPOTENCY_KEY_REUSED`.'
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      error:
                        $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: >-
        Partner-generated UUID; the ONE dedup key for all mutating endpoints.
        24h TTL. Same key + same payload -> byte-identical replay; same key +
        different payload -> IDEMPOTENCY_KEY_REUSED (422).
      schema:
        type: string
        format: uuid
  schemas:
    ClawbackGrantRequest:
      type: object
      description: Clawback a promotional grant (ops).
      required:
        - meta
        - reason
      properties:
        meta:
          $ref: '#/components/schemas/RequestMeta'
        reason:
          type: string
          enum:
            - SOURCE_ORDER_VOIDED
            - SOURCE_REFUNDED
            - FRAUD
            - DUPLICATE
            - OTHER
          description: Why the grant is being clawed back.
        note:
          type:
            - string
            - 'null'
          description: Free-text note for the audit trail.
    ResponseEnvelope:
      type: object
      description: >-
        The standard response envelope that every enveloped endpoint serializes
        through. `ok` is a boolean discriminator: when `ok` is `true`, the typed
        result is carried in `data`; when `ok` is `false`, a typed error object
        is returned instead. The `meta` object is uniform across the entire API
        surface.
      required:
        - ok
        - meta
      properties:
        ok:
          type: boolean
        data:
          type:
            - object
            - 'null'
        error:
          oneOf:
            - $ref: '#/components/schemas/Error'
            - type: 'null'
        meta:
          $ref: '#/components/schemas/Meta'
    ClawbackResult:
      type: object
      description: >-
        The outcome of a clawback. `spent_loss_logged` is any already-spent
        promotional portion booked as a merchant loss; it is never pulled from
        the customer's actual cash balance.
      required:
        - grant_id
        - state
        - clawed_back
      properties:
        grant_id:
          type: string
        state:
          type: string
          enum:
            - CLAWED_BACK
        clawed_back:
          $ref: '#/components/schemas/Money'
        spent_loss_logged:
          $ref: '#/components/schemas/Money'
        clawed_at:
          type: string
          format: date-time
    Error:
      type: object
      description: >-
        The typed error object returned with every non-2xx response. `code` is a
        string enum (for example `WALLET_PROGRAM_AMBIGUOUS`,
        `CREDENTIAL_TYPE_UNSUPPORTED`, `INSUFFICIENT_FUNDS`,
        `IDEMPOTENCY_KEY_REUSED`, `CURRENCY_NOT_SUPPORTED`), **never a bare HTTP
        status number**. Inspect `code` for programmatic branching, not the HTTP
        status. Some codes echo the valid set in `details` so clients can
        present or reconcile the accepted values: for example
        `CREDENTIAL_TYPE_UNSUPPORTED` lists the supported credential types,
        `CURRENCY_NOT_SUPPORTED` lists the supported ISO-4217 currencies, and
        `WALLET_PROGRAM_AMBIGUOUS` lists the candidate `wallet_program_id`
        values that matched the request.
      required:
        - code
        - message
      properties:
        code:
          type: string
          enum:
            - INSUFFICIENT_FUNDS
            - INVALID_API_KEY
            - CREDENTIAL_TYPE_UNSUPPORTED
            - CURRENCY_NOT_SUPPORTED
            - IDEMPOTENCY_KEY_REUSED
            - WALLET_PROGRAM_AMBIGUOUS
            - REQUIRES_DYNAMIC_CREDENTIAL
            - NOT_FOUND
            - FORBIDDEN
            - VALIDATION_ERROR
            - RATE_LIMITED
            - CONFLICT
            - INTERNAL_SERVER_ERROR
        message:
          type: string
        details:
          type: object
          additionalProperties: true
    RequestMeta:
      type: object
      description: >-
        Common request metadata shared across all Partner API domains.
        `partner_request_id` is a correlation identifier only: it appears in
        logs and responses for tracing but is **never used as the deduplication
        key**. Request deduplication is keyed exclusively on the
        `Idempotency-Key` header.
      required:
        - partner_request_id
        - api_version
      properties:
        partner_request_id:
          type: string
          format: uuid
          description: Partner's own correlation id. NOT the idempotency basis.
        occurred_at:
          type: string
          format: date-time
          description: >-
            When the event happened at the POS (RFC3339). Clock-drift signal vs
            sent_at.
        sent_at:
          type: string
          format: date-time
          description: When the partner sent the request (RFC3339).
        api_version:
          type: string
          description: The single API version field.
          example: '2026-06-01'
    Meta:
      type: object
      description: >-
        The uniform response metadata block returned on every response.
        `data_completeness_score` is computed per call and reports the
        completeness of the returned data. `decision_trace_id` is present on
        responses that carry decision or insight output and can be used to
        correlate the response with its reasoning. `capabilities` is an
        additive, response-level array of hints advertising features the caller
        may use, and may be extended over time without notice.
      required:
        - request_id
        - api_version
      properties:
        request_id:
          type: string
          description: Feddi-issued correlation id for this response.
        idempotency_replayed:
          type: boolean
          description: True when this response was replayed from the idempotency store.
        api_version:
          type: string
          description: The single API version field.
          example: '2026-06-01'
        data_completeness_score:
          type: integer
          minimum: 0
          maximum: 100
          description: >-
            0-100, computed per call (basket/identity/tax/category/consent
            presence).
        decision_trace_id:
          type:
            - string
            - 'null'
          description: Opaque trace id on intelligence-bearing responses; one per response.
        capabilities:
          type: object
          additionalProperties: true
          description: Additive response-level capability hints.
    Money:
      type: object
      description: >-
        Server-authoritative monetary value. Always expressed as a minor-units
        integer paired with an explicit ISO-4217 `currency` code. This is a
        ledger and reporting shape used to report amounts and balances, **never
        a custody or stored-value token**.
      required:
        - amount_minor
        - currency
      properties:
        amount_minor:
          type: integer
          description: Amount in minor units (e.g. fils, cents).
        currency:
          type: string
          minLength: 3
          maxLength: 3
          description: ISO-4217 currency code.
          example: QAR
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Partner API key (platform- or merchant-scoped). Contract key-enforces
        context.merchant_id.

````