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

# Reserve coupons

> Reserve coupons in order to disallow to use same coupon simultaneously. 

Coupon will be reserved until the time specified in ReservedUntil. 

ReservedBy specifies the system that reserved coupons. 

If the reservation is not already populated (ReservedBy and ReservedUntil), 
new values will be set. However, if ReservedBy is already populated and the reservation is still active (ReservedUntil > CurrentTime), 
and a new ReservedBy value is provided in the request, an error will be returned.
If the ReservedBy value matches the already populated value, the reserver can edit the reservation time and reserve more coupons.



## OpenAPI

````yaml openapi/coupon-v1.json POST /api/v1/customers/{customerId}/coupons/reserve
openapi: 3.0.4
info:
  title: Coupon.Api
  version: v1
servers:
  - url: https://{host}/coupon
    description: Your Lobyco environment
    variables:
      host:
        default: your-environment.lobyco.net
        description: >-
          The API host for your Lobyco environment. Replace it with the host you
          were given — this placeholder does not resolve.
security: []
paths:
  /api/v1/customers/{customerId}/coupons/reserve:
    post:
      tags:
        - Customers
      summary: Reserve coupons
      description: >-
        Reserve coupons in order to disallow to use same coupon simultaneously. 


        Coupon will be reserved until the time specified in ReservedUntil. 


        ReservedBy specifies the system that reserved coupons. 


        If the reservation is not already populated (ReservedBy and
        ReservedUntil), 

        new values will be set. However, if ReservedBy is already populated and
        the reservation is still active (ReservedUntil > CurrentTime), 

        and a new ReservedBy value is provided in the request, an error will be
        returned.

        If the ReservedBy value matches the already populated value, the
        reserver can edit the reservation time and reserve more coupons.
      parameters:
        - name: customerId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/Coupon.Client.Models.Request.ReserveCouponsRequest
          text/json:
            schema:
              $ref: >-
                #/components/schemas/Coupon.Client.Models.Request.ReserveCouponsRequest
          application/*+json:
            schema:
              $ref: >-
                #/components/schemas/Coupon.Client.Models.Request.ReserveCouponsRequest
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Coupon.Client.Models.Response.ReserveCouponsResponse
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/LoopFoundation.Commons.Contracts.WebServiceError
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/LoopFoundation.Commons.Contracts.WebServiceError
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
components:
  schemas:
    Coupon.Client.Models.Request.ReserveCouponsRequest:
      required:
        - couponIds
        - reservedBy
        - reservedUntil
      type: object
      properties:
        reservedBy:
          minLength: 1
          type: string
        reservedUntil:
          type: string
          format: date-time
        couponIds:
          type: array
          items:
            type: string
      additionalProperties: false
    Coupon.Client.Models.Response.ReserveCouponsResponse:
      type: object
      properties:
        couponIds:
          type: array
          items:
            type: string
          nullable: true
      additionalProperties: false
    LoopFoundation.Commons.Contracts.WebServiceError:
      required:
        - message
        - name
      type: object
      properties:
        name:
          minLength: 1
          type: string
        message:
          minLength: 1
          type: string
        details:
          nullable: true
      additionalProperties: false
    Microsoft.AspNetCore.Mvc.ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}

````