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

# Apply a discount code to a checkout



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/commerce/checkouts/{id}/discount
openapi: 3.1.0
info:
  title: VaultGraph Portal API
  version: 0.1.1
  description: Server-to-server endpoints exposed by the VaultGraph portal (beta).
servers:
  - url: https://app.vaultgraph.com
    description: Production
security: []
tags:
  - name: Shops
    description: Shop management endpoints.
  - name: Commerce
    description: >-
      Deployment-scoped commerce endpoints (catalog, checkout, order).
      Authenticated with a deployment (`dk_`) API key. Internal plumbing between
      the hosted MCP server and the merchant adapter — merchants integrate via
      the MCP, not these REST routes.
paths:
  /api/commerce/checkouts/{id}/discount:
    post:
      tags:
        - Commerce
      summary: Apply a discount code to a checkout
      operationId: applyCheckoutDiscount
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - code
              properties:
                code:
                  type: string
      responses:
        '200':
          description: Updated checkout
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CheckoutResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CheckoutResponse:
      type: object
      required:
        - id
        - currency
        - status
        - line_items
        - links
        - totals
        - payment
        - ucp
      properties:
        id:
          type: string
        currency:
          type: string
        status:
          type: string
          enum:
            - canceled
            - complete_in_progress
            - completed
            - incomplete
            - ready_for_complete
            - requires_escalation
        line_items:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/LineItem'
              - type: object
                properties:
                  item:
                    $ref: '#/components/schemas/Item'
                  totals:
                    type: array
                    items:
                      $ref: '#/components/schemas/Total'
        totals:
          type: array
          items:
            $ref: '#/components/schemas/Total'
        buyer:
          $ref: '#/components/schemas/Buyer'
        links:
          type: array
          items:
            $ref: '#/components/schemas/CheckoutLink'
        payment:
          $ref: '#/components/schemas/CheckoutPayment'
        ucp:
          $ref: '#/components/schemas/UcpEnvelope'
    LineItem:
      type: object
      required:
        - item
        - quantity
      properties:
        id:
          type: string
        item:
          type: object
          required:
            - id
          properties:
            id:
              type: string
              description: References an Item.id.
        quantity:
          type: integer
          minimum: 1
        parent_id:
          type: string
        properties:
          type: array
          description: >-
            Merchant-defined custom fields, each a { name, value } pair (e.g. an
            engraving or gift message). Echoed on the order; lines of the same
            item with different properties stay separate.
          items:
            type: object
            required:
              - name
              - value
            properties:
              name:
                type: string
              value:
                type: string
    Item:
      type: object
      required:
        - id
        - title
        - price
      properties:
        id:
          type: string
        title:
          type: string
        price:
          type: integer
          description: Integer minor units.
        image_url:
          type: string
    Total:
      type: object
      required:
        - type
        - amount
      properties:
        type:
          type: string
          enum:
            - subtotal
            - discount
            - items_discount
            - fulfillment
            - tax
            - fee
            - total
        amount:
          type: integer
        display_text:
          type: string
    Buyer:
      type: object
      properties:
        email:
          type: string
        first_name:
          type: string
        full_name:
          type: string
        last_name:
          type: string
        phone_number:
          type: string
    CheckoutLink:
      type: object
      properties:
        title:
          type: string
        type:
          type: string
        url:
          type: string
      required:
        - type
        - url
      additionalProperties: false
    CheckoutPayment:
      type: object
      properties:
        handlers:
          type: array
          items:
            type: object
            properties:
              config:
                type: object
                additionalProperties: {}
              config_schema:
                type: string
              id:
                type: string
              instrument_schemas:
                type: array
                items:
                  type: string
              name:
                type: string
              spec:
                type: string
              version:
                type: string
            required:
              - config
              - config_schema
              - id
              - instrument_schemas
              - name
              - spec
              - version
            additionalProperties: false
        instruments:
          type: array
          items:
            type: object
            properties:
              billing_address:
                type: object
                properties:
                  address_country:
                    type: string
                  address_locality:
                    type: string
                  address_region:
                    type: string
                  extended_address:
                    type: string
                  first_name:
                    type: string
                  full_name:
                    type: string
                  last_name:
                    type: string
                  phone_number:
                    type: string
                  postal_code:
                    type: string
                  street_address:
                    type: string
                additionalProperties: false
              credential:
                type: object
                properties:
                  type:
                    type: string
                  card_number_type:
                    type: string
                    enum:
                      - dpan
                      - fpan
                      - network_token
                  cryptogram:
                    type: string
                  cvc:
                    type: string
                  eci_value:
                    type: string
                  expiry_month:
                    type: number
                  expiry_year:
                    type: number
                  name:
                    type: string
                  number:
                    type: string
                required:
                  - type
                additionalProperties: false
              handler_id:
                type: string
              id:
                type: string
              type:
                type: string
                enum:
                  - card
              brand:
                type: string
              expiry_month:
                type: number
              expiry_year:
                type: number
              last_digits:
                type: string
              rich_card_art:
                type: string
              rich_text_description:
                type: string
            required:
              - handler_id
              - id
              - type
              - brand
              - last_digits
            additionalProperties: false
        selected_instrument_id:
          type: string
      required:
        - handlers
      additionalProperties: false
    UcpEnvelope:
      type: object
      properties:
        capabilities:
          type: array
          items:
            type: object
            properties:
              config:
                type: object
                additionalProperties: {}
              extends:
                type: string
              name:
                type: string
              schema:
                type: string
              spec:
                type: string
              version:
                type: string
            required:
              - name
              - version
            additionalProperties: false
        version:
          type: string
      required:
        - capabilities
        - version
      additionalProperties: false
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````