Pencil Discount codes API

The Discount codes API from Pencil — 3 operation(s) for discount codes.

GitHub OpenAPI

Operations 5

GET /discount-codes List discount codes (site admin) #
POST /discount-codes Create a discount code (site admin) #
PATCH /discount-codes/{code} Edit unused discount code terms (site admin) #
GET /discount-codes/{code} Inspect a discount code (site admin) #
POST /discount-codes/{code}/deactivate Deactivate a discount code (site admin) #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/pencil-ink:pencil-ink-discount-codes-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

pencil-ink-discount-codes-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Pencil Public Discount codes API
  version: 1.0.0
  description: 'Programmatic access to Pencil tasks, projects, agents, ideas, content, phases, and meetings.


    **Authentication.** Every request must send an org-scoped API key as a bearer token:


    ```

    Authorization: Bearer pk_live_…

    ```


    Create and manage keys in Pencil under **Settings → API Keys**. A key is scoped to a single organization — the org is determined by the key, so you never pass an org id. Each key carries a single coarse role:


    - `read` — may call any `GET` endpoint.

    - `write` — may additionally call `POST`/`PATCH`/`DELETE`. A read-only key calling a write endpoint gets `403`.


    **Responses.** Single resources are wrapped as `{ "data": … }`. List endpoints return `{ "data": [...], "pagination": { "nextCursor": string | null, "hasMore": boolean } }`; pass the returned `nextCursor` back as the `cursor` query param to page. Errors use `{ "error": { "code": …, "message": … } }`.


    **Rate limits.** Requests are limited per key. Exceeding the limit returns `429` with a `Retry-After` header (seconds until the window resets).'
servers:
- url: https://app.pencil.ink/api/v1
  description: This deployment
security:
- bearerAuth: []
tags:
- name: Discount codes
paths:
  /discount-codes:
    get:
      tags:
      - Discount codes
      operationId: listDiscountCodes
      summary: List discount codes (site admin)
      description: Requires an explicitly enabled discount-management key whose creator remains a site admin and organization admin. Platform-wide. Returns offers, enabled, and nextCursor (null on the last page).
      parameters:
      - name: cursor
        in: query
        schema:
          type: string
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 25
      responses:
        '200':
          description: The resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DiscountCodePage'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
      - Discount codes
      operationId: createDiscountCode
      summary: Create a discount code (site admin)
      description: Requires a write key with explicit discount-management permission and a current site-admin creator. Single-use; terms editable until redemption starts. Omit recipient IDs for shareable signup redemption. Does not enable global redemption or call Stripe. On uncertain completion, GET the same code before retrying.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                code:
                  type: string
                  description: Unique code, 6–64 letters, digits, dashes or underscores; normalized to uppercase.
                label:
                  type: string
                  maxLength: 40
                percentOff:
                  type: integer
                  minimum: 1
                  maximum: 100
                duration:
                  type: string
                  enum:
                  - once
                  - repeating
                  - forever
                months:
                  type: integer
                  minimum: 1
                  maximum: 36
                  description: Required for repeating duration.
                planKey:
                  type: string
                  enum:
                  - pro
                  - team
                  description: USD monthly base subscription only; excludes AI usage.
                targetOrgId:
                  type: string
                  description: Optional recipient organization. Recipient-targeted codes are single-use.
                targetUserId:
                  type: string
                  description: Optional recipient user; mutually exclusive with targetOrgId.
                maxRedemptions:
                  anyOf:
                  - type: integer
                    minimum: 1
                    maximum: 10000
                  - type: 'null'
                  description: Maximum distinct organization redemptions. Null means unlimited. Defaults to 1 and must be 1 for recipient-targeted codes.
                redeemFrom:
                  type: number
                  description: Optional redemption start, Unix milliseconds.
                redeemBy:
                  type: number
                  description: Optional future redemption deadline, Unix milliseconds.
              required:
              - code
              - label
              - percentOff
              - duration
              - planKey
      responses:
        '201':
          description: The resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DiscountCode'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Code already exists.
        '429':
          $ref: '#/components/responses/RateLimited'
  /discount-codes/{code}:
    parameters:
    - name: code
      in: path
      required: true
      schema:
        type: string
    patch:
      tags:
      - Discount codes
      operationId: updateDiscountCode
      summary: Edit unused discount code terms (site admin)
      description: Requires a write discount-management key and current site-admin creator. Updates supplied fields only. Set duration=repeating and months=12 for twelve months. redeemBy=null clears the deadline. Code and recipient cannot change. Any redemption history locks terms; no Stripe changes are made. Identical updates are no-ops.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                label:
                  type: string
                  maxLength: 40
                percentOff:
                  type: integer
                  minimum: 1
                  maximum: 100
                duration:
                  type: string
                  enum:
                  - once
                  - repeating
                  - forever
                months:
                  type: integer
                  minimum: 1
                  maximum: 36
                  description: Required for repeating duration.
                planKey:
                  type: string
                  enum:
                  - pro
                  - team
                  description: USD monthly base subscription only; excludes AI usage.
                maxRedemptions:
                  anyOf:
                  - type: integer
                    minimum: 1
                    maximum: 10000
                  - type: 'null'
                  description: Maximum distinct organization redemptions. Null means unlimited. Defaults to 1 and must be 1 for recipient-targeted codes.
                redeemFrom:
                  anyOf:
                  - type: number
                    description: Optional redemption start, Unix milliseconds.
                  - type: 'null'
                  description: Unix milliseconds; null clears the start.
                redeemBy:
                  anyOf:
                  - type: number
                    description: Optional future redemption deadline, Unix milliseconds.
                  - type: 'null'
                  description: Future Unix milliseconds; null clears the deadline.
      responses:
        '200':
          description: The resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DiscountCode'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Terms are locked because redemption has started.
        '429':
          $ref: '#/components/responses/RateLimited'
    get:
      tags:
      - Discount codes
      operationId: getDiscountCode
      summary: Inspect a discount code (site admin)
      description: Requires an explicitly enabled discount-management key and current site-admin creator. Includes redemption and up to ten recent audit events.
      responses:
        '200':
          description: The resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DiscountCodeDetail'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
  /discount-codes/{code}/deactivate:
    parameters:
    - name: code
      in: path
      required: true
      schema:
        type: string
    post:
      tags:
      - Discount codes
      operationId: deactivateDiscountCode
      summary: Deactivate a discount code (site admin)
      description: Requires a write discount-management key and current site-admin creator. Prevents future redemption; preserves applied discounts. Repeat-safe. Pending redemptions require reconciliation first.
      responses:
        '200':
          description: The resource.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DiscountCode'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Pending redemption must be reconciled.
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  responses:
    Unauthorized:
      description: Missing or invalid API key (`unauthorized`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The key is read-only and may not write (`forbidden`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit exceeded (`rate_limited`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds until the rate-limit window resets.
    NotFound:
      description: Resource not found in this org (`not_found`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ValidationError:
      description: Malformed request or invalid field (`validation_error`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    DiscountCodePage:
      type: object
      properties:
        offers:
          type: array
          items:
            $ref: '#/components/schemas/DiscountCode'
        enabled:
          type: boolean
        nextCursor:
          type:
          - string
          - 'null'
    DiscountCodeDetail:
      allOf:
      - $ref: '#/components/schemas/DiscountCode'
      - type: object
        properties:
          redemption:
            type:
            - object
            - 'null'
            additionalProperties: true
          audit:
            type: array
            items:
              type: object
              additionalProperties: true
    DiscountCode:
      type: object
      properties:
        code:
          type: string
          description: Unique code, 6–64 letters, digits, dashes or underscores; normalized to uppercase.
        label:
          type: string
          maxLength: 40
        percentOff:
          type: integer
          minimum: 1
          maximum: 100
        duration:
          type: string
          enum:
          - once
          - repeating
          - forever
        months:
          type: integer
          minimum: 1
          maximum: 36
          description: Required for repeating duration.
        planKey:
          type: string
          enum:
          - pro
          - team
          description: USD monthly base subscription only; excludes AI usage.
        targetOrgId:
          type: string
          description: Optional recipient organization. Recipient-targeted codes are single-use.
        targetUserId:
          type: string
          description: Optional recipient user; mutually exclusive with targetOrgId.
        maxRedemptions:
          anyOf:
          - type: integer
            minimum: 1
            maximum: 10000
          - type: 'null'
          description: Maximum distinct organization redemptions. Null means unlimited. Defaults to 1 and must be 1 for recipient-targeted codes.
        redeemFrom:
          type: number
          description: Optional redemption start, Unix milliseconds.
        redeemBy:
          type: number
          description: Optional future redemption deadline, Unix milliseconds.
        _id:
          type: string
        _creationTime:
          type: number
        active:
          type: boolean
        createdBy:
          type: string
        createdAt:
          type: number
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
              - unauthorized
              - forbidden
              - rate_limited
              - validation_error
              - phase_gate_locked
              - conflict
              - not_found
              - internal_error
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Org-scoped API key, e.g. `pk_live_…`.