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

# Create order

> Places an order for one or more rewards.

### Email Rewards
Orders are delivered via Giftbit email by default, and at least one
valid `contacts` entry is required.

### Shortlnk Rewards
Optionally, you can set `delivery_type: SHORTLINK` to create shortlink rewards that don't require any `contacts`.
Shortlink rewards use the same endpoint, return the same order object,
but generate links you can distribute yourself. When using
`delivery_type: SHORTLINK` include a `link_count` to specify the number of rewards to create.

### Order Configuration
The use of `gift_template` is optional, but all required parameters must be
specified in the API call, or set in the template.

Include the optional `expiry` parameter to create a promotional reward with a limited claim period.

If you do not specify `delivery_type`, the request defaults to an email reward delivered by Giftbit.




## OpenAPI

````yaml /api-reference/openapi.yaml post /campaign
openapi: 3.1.0
info:
  title: Giftbit API
  version: v1
  description: >
    Giftbit's REST API lets you automatically order rewards and send them to
    your

    recipients. Delivery can be handled either by links that integrate into
    another

    system's workflow, or by emails sent through the Giftbit system.


    Authenticate every request with a bearer token in the `Authorization`
    header.

    Only an HTTP `200` means success; all non-`200` responses share a common
    error body.
  contact:
    name: Giftbit Support
    email: testbed@giftbit.com
    url: https://www.giftbit.com/api-documentation
servers:
  - url: https://api-testbed.giftbit.com/papi/v1
    description: Testbed
  - url: https://api.giftbit.com/papi/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Ping
    description: Test your authentication and check the health of the Giftbit API.
  - name: Brands
    description: List reward brands and retrieve extended information about a single brand.
  - name: Regions
    description: List the regions used to filter brands and request Full Catalog rewards.
  - name: Email Orders
    description: Order one or more rewards delivered to recipients by Giftbit email.
  - name: Shortlink Orders
    description: Order branded shortlink rewards that include a customized landing page.
  - name: Direct Link Orders
    description: >-
      Order minimally branded direct link rewards returned immediately in the
      response.
  - name: Embedded Rewards
    description: >-
      Order a single in-app reward for immediate delivery in your app or
      website.
  - name: Funds
    description: Retrieve your account balance and top it up with a credit card payment.
  - name: Rewards
    description: List, retrieve, resend, and cancel individual rewards.
paths:
  /campaign:
    post:
      tags:
        - Email Orders
      summary: Create order
      description: >
        Places an order for one or more rewards.


        ### Email Rewards

        Orders are delivered via Giftbit email by default, and at least one

        valid `contacts` entry is required.


        ### Shortlnk Rewards

        Optionally, you can set `delivery_type: SHORTLINK` to create shortlink
        rewards that don't require any `contacts`.

        Shortlink rewards use the same endpoint, return the same order object,

        but generate links you can distribute yourself. When using

        `delivery_type: SHORTLINK` include a `link_count` to specify the number
        of rewards to create.


        ### Order Configuration

        The use of `gift_template` is optional, but all required parameters must
        be

        specified in the API call, or set in the template.


        Include the optional `expiry` parameter to create a promotional reward
        with a limited claim period.


        If you do not specify `delivery_type`, the request defaults to an email
        reward delivered by Giftbit.
      operationId: create-order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignCreateRequest'
            examples:
              email:
                summary: Email order
                value:
                  gift_template: XDKHE
                  contacts:
                    - firstname: Perry
                      lastname: Johnson
                      email: pjohnson@giftbit.com
                    - firstname: Rita
                      lastname: Robson
                      email: rrobson@giftbit.com
                  price_in_cents: 5000
                  brand_codes:
                    - itunesus
                    - amazonus
                  expiry: '2018-11-01'
                  id: clientProvidedGiftId_abc123
              shortlink:
                summary: Shortlink order
                value:
                  gift_template: XDKHE
                  delivery_type: SHORTLINK
                  link_count: 1
                  price_in_cents: 2500
                  brand_codes:
                    - itunesus
                    - amazonus
                  expiry: '2023-07-07'
                  id: clientProvidedGiftId_abc123
      responses:
        '200':
          description: Order creation has begun.
          content:
            application/json:
              schema:
                type: object
                properties:
                  info:
                    $ref: '#/components/schemas/Info'
                  status:
                    type: integer
                  campaign:
                    $ref: '#/components/schemas/Campaign'
              example:
                info:
                  code: INFO_CAMPAIGN_CREATED
                  name: Campaign Created
                  message: Campaign creation has begun.
                status: 200
                campaign:
                  company_name: Company Name
                  message: Thanks for being such an awesome customer!
                  subject: Please enjoy this reward!
                  contacts:
                    - email: pjhonson@giftbit.com
                      firstname: Perry
                      added_successfully: true
                      lastname: Johnson
                      message: Contact ready
                  price_in_cents: 5000
                  brand_codes:
                    - itunesus
                    - amazonus
                  status: API_CREATING
                  uuid: 9a405b513c11413aaac593a0c2e1a15d
                  suppress_default_greeting: false
                  delivery_type: GIFTBIT_EMAIL
                  expiry: '2017-05-01'
                  contacts_success_count: 2
                  contacts_failure_count: 0
                  gift_template: XDKHE
                  id: clientProvidedGiftId_abc123
        '422':
          description: One or more parameters are not valid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: ERROR_CAMPAIGN_INVALID_BRAND
                  name: Invalid Brand or Brand/Price combination
                  message: >-
                    brand_code: itunesus - price_in_cents: 50000 - The
                    brand_code provided is not valid or not available for the
                    given price
                status: 422
components:
  schemas:
    CampaignCreateRequest:
      type: object
      required:
        - price_in_cents
        - id
      properties:
        message:
          type: string
          description: Reward email message. Required if no supplied template.
        subject:
          type: string
          description: Reward email subject. Required if no supplied template.
        gift_template:
          type: string
          description: The template id used for this order.
        contacts:
          type: array
          items:
            $ref: '#/components/schemas/Contact'
          description: A list of contact objects. Required for email delivery.
        price_in_cents:
          type: integer
          description: The value of the offer in cents.
        brand_codes:
          type: array
          items:
            type: string
          description: >-
            Custom list of one or more brand_code. Not applicable to Full
            Catalog choice.
        region:
          type: string
          description: Region for the Full Catalog from which recipients select a brand.
        delivery_type:
          type: string
          enum:
            - GIFTBIT_EMAIL
            - SHORTLINK
          description: >-
            Optional. Defaults to email delivery. Set to SHORTLINK to create
            shortlink rewards from this same `/campaign` endpoint instead of
            having Giftbit deliver the reward by email.
        link_count:
          type: integer
          description: >-
            Optional. For shortlink orders, the number of reward links to
            generate. Include this when `delivery_type` is `SHORTLINK`.
        expiry:
          type: string
          description: >-
            The order's claim-before date (YYYY-MM-dd). May not exceed one year
            from creation.
        id:
          type: string
          description: >-
            A unique client-assigned identifier for the order. Idempotent on
            retry.
    Info:
      type: object
      description: Status information returned on successful requests.
      properties:
        code:
          type: string
          description: An enum-style status code for the request.
        name:
          type: string
          description: Human-readable status name.
        message:
          type: string
          description: Request-context-specific message.
    Campaign:
      type: object
      description: An order object.
      properties:
        company_name:
          type: string
        message:
          type: string
        subject:
          type:
            - string
            - 'null'
        contacts:
          type:
            - array
            - 'null'
          items:
            type: object
        price_in_cents:
          type: integer
        brand_codes:
          type: array
          items:
            type: string
        region:
          type: string
          description: 'Full Catalog region name. Possibilities: USA, Canada.'
        status:
          type: string
          enum:
            - API_CREATING
            - AWAITING_FUNDS
            - CAMPAIGN_CREATED
        uuid:
          type: string
        suppress_default_greeting:
          type: boolean
        delivery_type:
          type: string
          enum:
            - GIFTBIT_EMAIL
            - SHORTLINK
            - DIRECT_LINK
        expiry:
          type: string
        contacts_success_count:
          type: integer
        contacts_failure_count:
          type: integer
        link_count:
          type: integer
        fees:
          $ref: '#/components/schemas/Fees'
        gift_template:
          type: string
        id:
          type: string
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Error'
        status:
          type: integer
          description: An integer that matches the HTTP status code returned.
    Contact:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
        firstname:
          type: string
        lastname:
          type: string
    Fees:
      type: object
      description: Information about the cost of the order and any associated fees.
      properties:
        cost_entries:
          type: array
          items:
            type: object
            properties:
              percentage:
                type: number
              fee_type:
                type: string
              amount_in_cents:
                type: integer
              currency:
                type: string
              tax_type:
                type: string
              tax_in_cents:
                type:
                  - integer
                  - 'null'
              number_of_gifts:
                type: integer
              fee_per_gift_in_cents:
                type: integer
        subtotal_in_cents:
          type: integer
        tax_in_cents:
          type: integer
        tax_type:
          type: string
        total_in_cents:
          type: integer
    Error:
      type: object
      properties:
        code:
          type: string
          description: An enum-style error code that will not change.
        name:
          type: string
          description: Human-readable error name.
        message:
          type: string
          description: Request-specific information about the error.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Send your API token prefixed by `Bearer ` in the `Authorization` header.

````