# Update Voucher

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/products/{product_id}/vouchers/{voucher_id}:
    patch:
      summary: Update Voucher
      deprecated: false
      description: |-
        Updates an existing voucher for a specified product.

        <Accordion title="🔑Scopes" defaultOpen>
            
          `products.read_write` - Products Read & Write
         
        </Accordion>
      operationId: update-product-voucher
      tags:
        - Default module/Apps/Merchant APIs/Products/Digital Vouchers
        - Digital Products
      parameters:
        - name: product_id
          in: path
          description: ''
          required: true
          example: a1477bb2-72ea-4be9-b2cf-093cefc721bb
          schema:
            type: string
        - name: voucher_id
          in: path
          description: ''
          required: true
          example: b9a21ac0-0c04-4706-bef9-a05270613092
          schema:
            type: string
        - name: Authorization
          in: header
          description: >-
            The Authorization token is a unique key given to the third-party
            application (Partner) by Zid. It is used to authenticate the API
            requests made by the Partner application. The token verifies the
            partner's identity and ensures they have permission to access Zid's
            API but does not provide any specific user or store information. It
            should be included in the header of API requests when the partner
            application needs to access Zid's API.
          required: true
          example: '{{Autherization}}'
          schema:
            type: string
        - name: Access-Token
          in: header
          description: >-
            An Access Token is a unique string that represents the authorization
            granted to a client (Partner application) by a user (Merchant or
            Store Manager) to access their protected resources. It is part of
            the OAuth 2.0 standard and is used to authenticate API requests on
            behalf of the user. Access Tokens have a limited lifespan and must
            be used within their validity period. Once expired, a new Access
            Token can be obtained using a Refresh Token. Access Tokens should be
            treated as sensitive information and must be kept secure to prevent
            unauthorized access to the user's data. If you do not have an
            `Access-Token`, but have the older alternative instead, i.e., the
            `X-Manager-Token`, then see the instructions
            [here](docs/Migrate-to-OAUTH-2.0.md) on how to obtain the
            `Access-Token`.
          required: true
          example: '{{Access-Token}}'
          schema:
            type: string
        - name: Store-Id
          in: header
          description: ''
          required: true
          example: '{{StoreId}}'
          schema:
            type: number
            examples:
              - 37213
        - name: Role
          in: header
          description: Role of the user.
          required: true
          example: Manager
          schema:
            type: string
            enum:
              - Manager
            examples:
              - Manager
        - name: Accept-Language
          in: header
          description: >-
            Preferred language for the response. Defaults to `en` if not
            specified.
          required: false
          example: en
          schema:
            type: string
            enum:
              - en
              - ar
            examples:
              - en
        - name: Content-Type
          in: header
          description: >-
            The Media Type of the body of the request. This is used to describe
            the structure of the data in the body.
          required: true
          example: application/json
          schema:
            type: string
            default: application/json
            enum:
              - application/json
              - multipart/form-data
              - application/x-www-form-urlencoded
      requestBody:
        content:
          application/json:
            schema:
              type: object
              x-examples:
                Example 1:
                  key: ABC123XYZ
                  status: SOLD
              required:
                - key
              properties:
                key:
                  type: string
                  description: >-
                    This field represents the unique code sent to your customer
                    to activate the digital product. This code is mandatory and
                    is used to identify the voucher.
                status:
                  type: string
                  description: This field indicates the current status of the voucher.
              x-apidog-orders:
                - key
                - status
              x-apidog-ignore-properties: []
            example:
              key: key-2
              serial_number: serial--2
              pin_code: pin-code--2
              expires_at: '2026-10-10 00:00:00'
              status: AVAAILABLE
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Digital-Products'
          headers: {}
          x-apidog-name: OK
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Response returned when the request cannot be authenticated
                  because the required credentials are missing, invalid, or
                  expired.
                properties:
                  status:
                    type: string
                    description: Indicates the overall status of the API response.
                    examples:
                      - error
                  message:
                    type: object
                    description: >-
                      Contains structured details explaining why the request
                      could not be authenticated.
                    properties:
                      type:
                        type: string
                        description: Indicates the category of the response message.
                        examples:
                          - error
                      code:
                        type: string
                        description: >-
                          A machine-readable code identifying the authentication
                          error. Returns null when no specific code is
                          available.
                        examples:
                          - UNAUTHORIZED
                        nullable: true
                      name:
                        type: string
                        description: >-
                          A short, human-readable title describing the
                          authentication error. Returns null when no title is
                          available.
                        examples:
                          - Unauthorized
                        nullable: true
                      description:
                        type: string
                        description: >-
                          A human-readable explanation of why the request could
                          not be authenticated. Returns null when no detailed
                          explanation is available.
                        examples:
                          - >-
                            Authentication credentials are missing, invalid, or
                            expired.
                        nullable: true
                    required:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-orders:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                examples:
                  - status: error
                    message:
                      type: error
                      code: UNAUTHORIZED
                      name: Unauthorized
                      description: >-
                        Authentication credentials are missing, invalid, or
                        expired.
                x-apidog-ignore-properties: []
              examples:
                '1':
                  summary: Example 1
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_MISSING
                      name: Sorry
                      description: Please login first.
                '2':
                  summary: Example 2
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Login session expired. Please login again.
                '3':
                  summary: Example 3
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Invalid authentication
          headers: {}
          x-apidog-name: Unauthorized
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Status of the error.
                  message:
                    $ref: '#/components/schemas/ResponseEnvelopMessage'
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: error
                message:
                  type: error
                  code: MSG_HIDDEN
                  name: Error
                  description: Internal Server Error
          headers: {}
          x-apidog-name: Internal Server error
      security: []
      x-apidog-folder: Default module/Apps/Merchant APIs/Products/Digital Vouchers
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/613905/apis/api-9148646-run
components:
  schemas:
    Digital-Products:
      type: object
      description: >-
        Digital Products is a feature that enables you to sell a digital product
        to your customers as a coupon or code, and each of your customers
        receives a specific and different coupon.
      properties:
        vouchers:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: >-
                  The unique identifier for the voucher. This field is mandatory
                  and is used to identify the voucher in the system.
                examples:
                  - '"0d6dc296-f757-4f11-83b2-6d5fddb6ad85"'
              key:
                type: string
                description: >-
                  The unique code sent to your customer to activate the digital
                  product. This code is mandatory and is used to identify the
                  voucher.
                examples:
                  - '"ABC123XYZ"'
              pin_code:
                type: string
                description: >-
                  pin_code is optional. It is just an extra key that is used for
                  vouchers that need two keys (for example, Jarir gift cards in
                  Saudi need a key and pin code).
              status:
                type: string
                description: "The current status of the voucher. Possible values include:\r\n\r\n- `AVAILABLE`: The voucher is available for use.\r\n- `SOLD`: The voucher has been sold.\r\n- `RESERVED`: The voucher is reserved for a customer.\r\n- `RETURNED`: The voucher has been returned.\r\nThis field is mandatory."
                examples:
                  - '"AVAILABLE"'
              serial_number:
                type: string
                description: >-
                  The serial number is just used for `stock-keeping` and is not
                  used as the key of the digital product.
                examples:
                  - '"SN123456"'
              expires_at:
                type: string
                description: >-
                  expires_at is optional, and it should be a DateTime in iso8601
                  format.
                examples:
                  - '"2024-12-31"'
              created_at:
                type: string
                description: >-
                  The timestamp indicating when the voucher was created. This
                  field is automatically generated by the system.
                examples:
                  - '"2024-01-01T12:00:00Z"'
              updated_at:
                type: string
                description: >-
                  The timestamp indicating the last time the voucher was
                  updated. This field is automatically generated by the system.
                examples:
                  - '"2024-01-01T12:00:00Z"'
            required:
              - id
              - key
              - status
            x-apidog-orders:
              - id
              - key
              - pin_code
              - status
              - serial_number
              - expires_at
              - created_at
              - updated_at
            x-apidog-ignore-properties: []
      x-examples:
        Example 1:
          vouchers:
            - id: 0d6dc296-f757-4f11-83b2-6d5fddb6ad85
              key: ABC123XYZ
              pin_code: '1234'
              status: AVAILABLE
              serial_number: SN123456
              expires_at: '2024-12-31'
              created_at: '2024-01-01T12:00:00Z'
              updated_at: '2024-01-01T12:00:00Z'
      x-apidog-orders:
        - vouchers
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ResponseEnvelopMessage:
      type: object
      properties:
        type:
          type: string
          description: Type of response message returned by the API.
          examples:
            - success
        code:
          type: string
          description: Response code returned by the API, if available.
          examples:
            - MSG_POPUP_OK
          nullable: true
        name:
          type: string
          description: Name or title of the response message, if available.
          examples:
            - Coupons
          nullable: true
        description:
          type: string
          description: Detailed description of the response message, if available.
          examples:
            - Coupons created successfully
          nullable: true
      required:
        - type
        - code
        - name
        - description
      description: Additional response metadata.
      x-apidog-orders:
        - type
        - code
        - name
        - description
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes: {}
servers:
  - url: https://api.zid.sa/
    description: Prod Env
security: []

```
