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

# Create digital card

> Issue a card from a template and email its QR code to the customer.

## POST `/cards/create`

Issue a card from a template and email its QR code to the customer.

Send `Authorization: Bearer YOUR_API_KEY` and `X-Device-ID: YOUR_DEVICE_ID`. Also send `X-Employee-Token: YOUR_EMPLOYEE_TOKEN`. See [authentication](https://tapcoupon.mintlify.site/authentication.md).

Returns `201 Created` with the card object. The identifier is `cardId`; customer data is stored separately and the card includes `customerEmail`.

Supply `customer.email` and `customer.contact.fullName`, plus any [mandatory customer fields](https://tapcoupon.mintlify.site/customer-data.md) configured for the account. Use nested `contact` and `address` objects.

For variable-value coupon templates (`isAmountSpecified: false`), supply a positive `amount` in cents. Fixed-value coupon templates use their configured amount. `testCard` defaults to false. Real issuance requires an active subscription and can generate a billing event; test issuance has a limited window and card count.

### Example request

```bash theme={null}
curl -X POST "https://tapcoupon.at/api/v1/cards/create" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Device-ID: YOUR_DEVICE_ID" \
  -H "X-Employee-Token: YOUR_EMPLOYEE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "templateId": "693869428d49e641ba110e17",
  "customer": {
    "email": "bob@example.com",
    "contact": {
      "fullName": "Bob Example",
      "phone": "+43123456789"
    },
    "address": {
      "line1": "Bakers Street 41",
      "city": "Vienna",
      "postalCode": "1010",
      "countryCode": "AT"
    },
    "birthdate": "1990-06-15T00:00:00Z",
    "privacyConsentGiven": true
  }
}'
```

### Example response fields

```json theme={null}
{
  "cardId": "2945823033425",
  "cardType": "couponCard",
  "activated": true,
  "amount": 5000,
  "amountLeft": 5000,
  "customerEmail": "bob@example.com",
  "testCard": false
}
```


## OpenAPI

````yaml api-reference/openapi.json POST /cards/create
openapi: 3.1.0
info:
  title: TapCoupon POS and partner API
  version: 1.0.0
  description: >-
    API-key POS operations, customer card views, and partner payment sessions.
    Verified against the tap_coupon backend on 2026-10-02. Dashboard /clients
    and administrative routes use separate authentication and are outside this
    reference.
servers:
  - url: https://tapcoupon.at/api/v1
security: []
paths:
  /cards/create:
    post:
      tags:
        - Cards
      summary: Create digital card
      description: Issue a card from a template and email its QR code to the customer.
      operationId: cards_create_digital
      parameters:
        - name: X-Device-ID
          in: header
          required: true
          description: Stable device identifier. API key binds to this value on first use.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                templateId:
                  type: string
                  description: MongoDB object id.
                  pattern: ^[a-fA-F0-9]{24}$
                amount:
                  type: integer
                  description: >-
                    Positive coupon amount in cents. Required for variable-value
                    coupon templates.
                  minimum: 1
                testCard:
                  type: boolean
                  description: >-
                    Request a test card, subject to the account test period and
                    card limit.
                customer:
                  $ref: '#/components/schemas/CustomerInput'
              required:
                - templateId
                - customer
            example:
              templateId: 693869428d49e641ba110e17
              customer:
                email: bob@example.com
                contact:
                  fullName: Bob Example
                  phone: '+43123456789'
                address:
                  line1: Bakers Street 41
                  city: Vienna
                  postalCode: '1010'
                  countryCode: AT
                birthdate: '1990-06-15T00:00:00Z'
                privacyConsentGiven: true
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Card'
              example:
                cardId: '2945823033425'
                cardType: couponCard
                activated: true
                amount: 5000
                amountLeft: 5000
                customerEmail: bob@example.com
                testCard: false
        '400':
          description: Invalid request, card type, balance, points, or location.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            Missing or invalid API key, device id, employee token, or
            credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Device binding mismatch, archived location, employee location
            restriction, or account restriction.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Rate limit exceeded. The response body is determined by the
            rate-limit middleware.
        '500':
          description: >-
            Server, subscription eligibility, test-window, or test-card-limit
            failure. Issuance currently wraps these repository failures as 500
            errors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
          employeeToken: []
components:
  schemas:
    CustomerInput:
      type: object
      properties:
        email:
          type: string
          format: email
          maxLength: 255
        contact:
          $ref: '#/components/schemas/Contact'
        address:
          anyOf:
            - $ref: '#/components/schemas/Address'
            - type: 'null'
        birthdate:
          type: string
          format: date-time
        privacyConsentGiven:
          type: boolean
      required:
        - email
        - contact
    Card:
      oneOf:
        - $ref: '#/components/schemas/BlankCard'
        - $ref: '#/components/schemas/CouponCard'
        - $ref: '#/components/schemas/LoyaltyCard'
        - $ref: '#/components/schemas/StatusCard'
        - $ref: '#/components/schemas/PointsCard'
      discriminator:
        propertyName: cardType
        mapping:
          blankCard: '#/components/schemas/BlankCard'
          couponCard: '#/components/schemas/CouponCard'
          loyaltyCard: '#/components/schemas/LoyaltyCard'
          statusCard: '#/components/schemas/StatusCard'
          pointsCard: '#/components/schemas/PointsCard'
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error.
        errorCode:
          type: string
          description: >-
            Handler errors include a machine-readable code; middleware errors
            may omit it.
      required:
        - error
    Contact:
      type: object
      properties:
        fullName:
          type: string
          maxLength: 200
        displayName:
          type: string
          maxLength: 100
        company:
          type: string
          maxLength: 100
        phone:
          type: string
          maxLength: 20
      required:
        - fullName
    Address:
      type: object
      properties:
        line1:
          type: string
          maxLength: 255
        line2:
          type: string
          maxLength: 255
        city:
          type: string
          maxLength: 100
        state:
          type: string
          maxLength: 100
        postalCode:
          type: string
          maxLength: 20
        countryCode:
          type: string
          description: Two-letter country code.
          minLength: 2
          maxLength: 2
      required:
        - line1
        - city
        - postalCode
        - countryCode
    BlankCard:
      allOf:
        - $ref: '#/components/schemas/BaseCard'
        - type: object
          properties:
            cardType:
              type: string
              enum:
                - blankCard
          required:
            - cardType
    CouponCard:
      allOf:
        - $ref: '#/components/schemas/BaseCard'
        - type: object
          properties:
            cardType:
              type: string
              enum:
                - couponCard
            amountLeft:
              type: integer
              description: Remaining balance in cents.
          required:
            - cardType
    LoyaltyCard:
      allOf:
        - $ref: '#/components/schemas/BaseCard'
        - type: object
          properties:
            cardType:
              type: string
              enum:
                - loyaltyCard
            scansNeeded:
              type: integer
            currentScans:
              type: integer
            rewardMessage:
              type: string
            amountRenews:
              type: integer
            originalAmountRenews:
              type: integer
            unlimitedRenews:
              type: boolean
          required:
            - cardType
    StatusCard:
      allOf:
        - $ref: '#/components/schemas/BaseCard'
        - type: object
          properties:
            cardType:
              type: string
              enum:
                - statusCard
            _:
              type: string
              description: MongoDB object id.
              pattern: ^[a-fA-F0-9]{24}$
            program:
              $ref: '#/components/schemas/StatusProgram'
            level:
              type: string
              description: MongoDB object id.
              pattern: ^[a-fA-F0-9]{24}$
            points:
              type: integer
              description: Progress within the current tier; not the lifetime total.
          required:
            - cardType
    PointsCard:
      allOf:
        - $ref: '#/components/schemas/BaseCard'
        - type: object
          properties:
            cardType:
              type: string
              enum:
                - pointsCard
            _:
              type: string
              description: MongoDB object id.
              pattern: ^[a-fA-F0-9]{24}$
            program:
              $ref: '#/components/schemas/PointsProgram'
            points:
              type: integer
              description: Spendable reward balance.
          required:
            - cardType
    BaseCard:
      type: object
      properties:
        id:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        cardId:
          type: string
          description: Reusable printed or digital card identifier.
        serialNumber:
          type: integer
        pocketId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        activatedAt:
          type: string
          format: date-time
        canceledAt:
          type: string
          format: date-time
        activated:
          type: boolean
        lifetime:
          type: integer
          description: Lifetime in hours, measured from createdAt; 0 means unlimited.
          minimum: 0
        description:
          type: string
        amount:
          type: integer
          description: Original coupon value in cents, or template amount for other types.
        location:
          $ref: '#/components/schemas/Location'
        createdByEmployeeId:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        archived:
          type: boolean
        testCard:
          type: boolean
        isLocationBound:
          type: boolean
          description: When true, use is restricted to the issuing location.
        customerEmail:
          type: string
        templateId:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        logs:
          type: array
          items:
            type: object
            properties:
              createdAt:
                type: string
                format: date-time
              cardId:
                type: string
              path:
                type: string
              method:
                type: string
              statusCode:
                type: integer
              employeeUsername:
                type: string
    StatusProgram:
      type: object
      properties:
        id:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        pocketId:
          type: string
        name:
          type: string
        description:
          type: string
        durationDays:
          type: integer
          description: Rolling points window in days.
          minimum: 1
          maximum: 36500
        levels:
          type: array
          items:
            $ref: '#/components/schemas/StatusLevel'
        archived:
          type: boolean
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    PointsProgram:
      type: object
      properties:
        id:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        pocketId:
          type: string
        name:
          type: string
        description:
          type: string
        rewardIds:
          type: array
          items:
            type: string
            description: MongoDB object id.
            pattern: ^[a-fA-F0-9]{24}$
        archived:
          type: boolean
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Location:
      type: object
      properties:
        id:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        pocketId:
          type: string
        name:
          type: string
        archived:
          type: boolean
      required:
        - id
        - name
    StatusLevel:
      type: object
      properties:
        id:
          type: string
          description: MongoDB object id.
          pattern: ^[a-fA-F0-9]{24}$
        name:
          type: string
        description:
          type: string
        points:
          type: integer
          description: Cost to advance from this level to the next.
          minimum: 0
        color:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Location API key. Also requires X-Device-ID.
    employeeToken:
      type: apiKey
      in: header
      name: X-Employee-Token
      description: Employee session token from /employee/login.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.