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

# Create an idempotent promotional credit claim

> The leadId is the idempotency key within the API access grant. An exact retry returns the existing claim; a retry with changed claim details returns 409.



## OpenAPI

````yaml /openapi.json post /api/public/v1/credit-claims
openapi: 3.1.0
info:
  title: Sparkles partner API
  version: 1.0.0
  description: Create promotional credit claims and receive attributed lifecycle events.
servers:
  - url: https://sparkles.dev
security: []
paths:
  /api/public/v1/credit-claims:
    post:
      tags:
        - partner credits
      summary: Create an idempotent promotional credit claim
      description: >-
        The leadId is the idempotency key within the API access grant. An exact
        retry returns the existing claim; a retry with changed claim details
        returns 409.
      operationId: createCreditClaim
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                leadId:
                  type: string
                  minLength: 1
                  maxLength: 200
                email:
                  type: string
                  maxLength: 320
                  format: email
                  pattern: >-
                    ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
                variant:
                  type: string
                  minLength: 1
                  maxLength: 100
                creditAmount:
                  type: integer
                  minimum: 1
                  maximum: 1000000
              required:
                - leadId
                - email
                - variant
                - creditAmount
              additionalProperties: false
      responses:
        '200':
          description: An identical claim already existed
          headers:
            Location:
              required: true
              description: Absolute URL of the credit claim status resource
              schema:
                type: string
                description: Absolute URL of the credit claim status resource
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  leadId:
                    type: string
                  variant:
                    type: string
                  creditAmount:
                    type: integer
                    exclusiveMinimum: 0
                    maximum: 9007199254740991
                  status:
                    type: string
                    enum:
                      - pending
                      - claimed
                      - cancelled
                  claimUrl:
                    type: string
                  statusUrl:
                    type: string
                  createdAt:
                    type: string
                  claimedAt:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - leadId
                  - variant
                  - creditAmount
                  - status
                  - claimUrl
                  - statusUrl
                  - createdAt
                  - claimedAt
                additionalProperties: false
        '201':
          description: Credit claim created
          headers:
            Location:
              required: true
              description: Absolute URL of the credit claim status resource
              schema:
                type: string
                description: Absolute URL of the credit claim status resource
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  leadId:
                    type: string
                  variant:
                    type: string
                  creditAmount:
                    type: integer
                    exclusiveMinimum: 0
                    maximum: 9007199254740991
                  status:
                    type: string
                    enum:
                      - pending
                      - claimed
                      - cancelled
                  claimUrl:
                    type: string
                  statusUrl:
                    type: string
                  createdAt:
                    type: string
                  claimedAt:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - leadId
                  - variant
                  - creditAmount
                  - status
                  - claimUrl
                  - statusUrl
                  - createdAt
                  - claimedAt
                additionalProperties: false
        '400':
          description: Malformed JSON or request fields failed validation
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '401':
          description: Missing, malformed, revoked, or otherwise invalid API key
          headers:
            WWW-Authenticate:
              required: true
              description: Bearer authentication challenge for the Sparkles partner API
              schema:
                type: string
                description: Bearer authentication challenge for the Sparkles partner API
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '409':
          description: >-
            The lead identifier conflicts with an existing claim or the grant
            budget is spent
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '413':
          description: Request body exceeded 16 KiB
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '415':
          description: Content-Type was not application/json
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '422':
          description: Credit amount exceeded the configured per-claim limit
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '429':
          description: The API key exceeded its distributed per-minute request limit
          headers:
            Retry-After:
              required: true
              description: Seconds until another request may be made
              schema:
                type: string
                pattern: ^\d+$
                description: Seconds until another request may be made
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '500':
          description: The request could not be completed because of an internal error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
      security:
        - partnerApiKey: []
components:
  securitySchemes:
    partnerApiKey:
      type: http
      scheme: bearer
      bearerFormat: spk_live_…
      description: >-
        Long-lived opaque API key minted by an approved user at /api. The secret
        is shown once, stored only as a SHA-256 digest, and disabled immediately
        when either the key or its API access grant is revoked.

````