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

# Update a coupon schedule

> Updates the configuration of an existing coupon schedule.



## OpenAPI

````yaml /api/en/captive-portal.yaml put /captive/instances/{instanceId}/coupon-schedules/{scheduleId}
openapi: 3.0.3
info:
  title: Altostrat Captive Portal API
  version: 1.0.0
  description: >-
    The Altostrat Captive Portal API is the microservice responsible for
    managing user authentication, access control, and branding for guest Wi-Fi
    networks.


    It acts as the control plane for guest network experiences on MikroTik
    devices within the Altostrat SDX platform, integrating with network
    automation to dynamically manage user sessions and access policies.


    This API allows you to programmatically manage:

    - **Instances:** A complete configuration for a captive portal, including
    its appearance (theme), authentication method (OAuth2 or coupon-based), and
    session rules.

    - **Auth Integrations:** Reusable configurations for third-party identity
    providers (e.g., Google, Azure AD) used in OAuth2 authentication strategies.

    - **Coupons & Schedules:** Time-limited access codes and the automated
    schedules that generate them for coupon-based guest access.

    - **Walled Garden:** Granular rules defining which domains or IP addresses
    users can access *before* authenticating, essential for identity provider
    logins.


    Developers use this API to programmatically create, configure, and manage
    bespoke guest Wi-Fi experiences across their entire network of sites.
servers:
  - url: https://v1.api.altostrat.io
    description: Altostrat Production API
security:
  - bearerAuth: []
tags:
  - name: Captive Portal Instances
    description: >-
      Manage captive portal configurations, including themes, authentication
      strategies, and associated sites.
  - name: Auth Integrations
    description: >-
      Configure third-party Identity Providers (IDPs) for OAuth2-based
      authentication.
  - name: Coupons
    description: Generate and manage single-use access coupons for guest networks.
  - name: Coupon Schedules
    description: Automate the generation of access coupons on a recurring schedule.
  - name: Walled Garden
    description: Control which destinations users can access before authentication.
  - name: Site Users
    description: >-
      View and manage users who have authenticated through the captive portal at
      a specific site.
  - name: Public Coupon URLs
    description: Signed public URLs for coupon schedule exports.
paths:
  /captive/instances/{instanceId}/coupon-schedules/{scheduleId}:
    put:
      tags:
        - Coupon Schedules
      summary: Update a coupon schedule
      description: Updates the configuration of an existing coupon schedule.
      operationId: updateCouponSchedule
      parameters:
        - $ref: '#/components/parameters/instanceId'
        - $ref: '#/components/parameters/scheduleId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CouponScheduleCreate'
      responses:
        '200':
          description: The coupon schedule was updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CouponSchedule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    instanceId:
      name: instanceId
      in: path
      required: true
      description: The unique identifier for the captive portal instance.
      schema:
        type: string
        format: uuid
        example: 9a7f1b2c-3d4e-5f6a-7b8c-9d0e1f2a3b4c
    scheduleId:
      name: scheduleId
      in: path
      required: true
      description: The unique identifier for the coupon schedule.
      schema:
        type: string
        format: uuid
        example: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
  schemas:
    CouponScheduleCreate:
      type: object
      required:
        - name
        - count
        - recurrence_type
        - valid_for_in_minutes
        - timezone
        - notification_group_id
      properties:
        name:
          type: string
          description: A human-readable name for the schedule.
          example: Daily Guest Passes
        count:
          type: integer
          description: The number of coupons to generate each time the schedule runs.
          minimum: 1
          maximum: 500
          example: 20
        recurrence_type:
          type: string
          enum:
            - daily
            - weekly
            - monthly
          description: How often the schedule should run.
          example: daily
        day_of_week:
          type: integer
          description: >-
            Required for 'weekly' recurrence. The day of the week to run
            (0=Sunday, 6=Saturday).
          minimum: 0
          maximum: 6
          nullable: true
          example: 1
        day_of_month:
          type: integer
          description: >-
            Required for 'monthly' recurrence. The day of the month to run
            (1-31).
          minimum: 1
          maximum: 31
          nullable: true
          example: 15
        valid_for_in_minutes:
          type: integer
          description: The number of minutes each generated coupon will be valid for.
          minimum: 1
          maximum: 90000
          example: 480
        timezone:
          type: string
          description: >-
            The timezone in which the schedule should be evaluated (e.g.,
            'America/New_York').
          example: Australia/Sydney
        notification_group_id:
          type: string
          description: The ID of a notification group to receive the generated coupons.
          example: ng_a1b2c3d4e5f6
    CouponSchedule:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The unique identifier for the coupon schedule.
          example: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
        name:
          type: string
          description: A human-readable name for the schedule.
          example: Daily Guest Passes
        instance_id:
          type: string
          format: uuid
          description: The ID of the instance this schedule belongs to.
          example: 9a7f1b2c-3d4e-5f6a-7b8c-9d0e1f2a3b4c
        count:
          type: integer
          description: The number of coupons to generate each time the schedule runs.
          example: 20
        recurrence_type:
          type: string
          enum:
            - daily
            - weekly
            - monthly
          description: How often the schedule should run.
          example: daily
        day_of_week:
          type: integer
          description: >-
            Required for 'weekly' recurrence. The day of the week to run
            (0=Sunday, 6=Saturday).
          nullable: true
          example: 1
        day_of_month:
          type: integer
          description: >-
            Required for 'monthly' recurrence. The day of the month to run
            (1-31).
          nullable: true
          example: 15
        valid_for_in_minutes:
          type: integer
          description: >-
            The number of minutes each generated coupon will be valid for after
            its creation.
          example: 480
        timezone:
          type: string
          description: >-
            The timezone in which the schedule should be evaluated (e.g.,
            'America/New_York').
          example: Australia/Sydney
        notification_group_id:
          type: string
          description: The ID of a notification group to receive the generated coupons.
          example: ng_a1b2c3d4e5f6
        last_run_at:
          type: string
          format: date-time
          description: The timestamp of the last time this schedule was successfully run.
          nullable: true
          example: '2025-10-29T08:00:00Z'
        next_run_at:
          type: string
          format: date-time
          description: The calculated timestamp of the next scheduled run.
          nullable: true
          example: '2025-10-30T08:00:00Z'
        tokens_used_since_last_run:
          type: integer
          description: The number of coupons from the last run that have been redeemed.
          example: 5
        tokens_generated_since_last_run:
          type: integer
          description: The total number of coupons generated in the last run.
          example: 20
        tokens_available_since_last_run:
          type: integer
          description: The number of valid, unredeemed coupons remaining from the last run.
          example: 15
        created_at:
          type: string
          format: date-time
          description: The timestamp when the schedule was created.
          example: '2025-10-20T14:30:00Z'
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          description: A broad category for the error (e.g., 'invalid_request_error').
          example: invalid_request_error
        code:
          type: string
          description: A short, unique string identifying the specific error.
          example: parameter_missing
        message:
          type: string
          description: A human-readable description of what went wrong.
          example: The 'name' parameter is required for this request.
        doc_url:
          type: string
          description: >-
            A direct link to the documentation page for this specific error
            code.
          example: https://docs.altostrat.io/errors/parameter_missing
  responses:
    BadRequest:
      description: >-
        Bad Request - The request was malformed or invalid. This can happen if a
        required parameter is missing or a value is of the wrong type.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: >-
        Unauthorized - The request requires authentication, but no valid
        credentials were provided. Ensure your API key is correct and included
        in the 'Authorization' header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: >-
        Forbidden - You do not have permission to perform this action on the
        requested resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: >-
        Not Found - The requested resource could not be found. Check that the
        provided ID is correct.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServerError:
      description: >-
        Internal Server Error - Something went wrong on our end. We've been
        notified and are looking into it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        API Key authentication. Provide your token in the 'Authorization'
        header. Example: `Authorization: Bearer <YOUR_TOKEN>`

````