## Create Custom Envelope

**post** `/print-mail/v1/custom_envelopes`

Creates a new custom envelope. The artwork is reviewed after it is
uploaded: the custom envelope is returned with a `status` of `pending`
and moves to `approved` or `rejected` once the review finishes. Create a custom envelope via a multipart/form-data request. Accepts the
same fields as the JSON create body; use this content type to upload the
PDF file directly.

### Header Parameters

- `"idempotency-key": optional string`

### Body Parameters

- `envelopeType: "standard_double_window" or "standard_single_window" or "standard_large_window" or 2 more`

  The type of a custom envelope. This determines the envelope's size and the
  windows that your artwork must leave clear.

  - `"standard_double_window"`

  - `"standard_single_window"`

  - `"standard_large_window"`

  - `"6x9_large_window"`

  - `"9x12_single_window"`

- `pdf: string or string`

  A URL pointing to the PDF of the custom envelope's artwork, or the PDF
  file itself. The PDF must have exactly two pages (front and back) at the
  dimensions of the chosen `envelopeType`.

  - `string`

  - `BinaryFile = string`

    Represents a raw file upload. Sending the actual file requires a
    `multipart/form-data` request; in `application/json` request bodies,
    supply a URL instead.

- `description: optional string`

  An optional string describing this resource. Will be visible in the API and the dashboard.

- `metadata: optional map[unknown]`

  See the section on Metadata.

### Returns

- `CustomEnvelope object { id, available, createdAt, 10 more }`

  - `id: string`

    A unique ID prefixed with custom_envelope_

  - `available: number`

    The quantity of custom envelopes available to use in your orders
    immediately. This increases when a custom envelope order is filled and
    decreases as you send orders which include this custom envelope.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `live: boolean`

    `true` if this is a live mode resource else `false`.

  - `object: "custom_envelope"`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: "pending" or "approved" or "rejected"`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `description: optional string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `envelopeType: optional "standard_double_window" or "standard_single_window" or "standard_large_window" or 2 more`

    The type of a custom envelope. This determines the envelope's size and the
    windows that your artwork must leave clear.

    - `"standard_double_window"`

    - `"standard_single_window"`

    - `"standard_large_window"`

    - `"6x9_large_window"`

    - `"9x12_single_window"`

  - `lowInventoryThreshold: optional CustomEnvelopeLowInventoryThreshold`

    A low-inventory threshold. When the available quantity of a custom envelope
    drops to or below the threshold, we send a low-inventory alert email to the
    Admins of your organization.

    An alert can only be sent once at least one order for the custom envelope
    has been filled. Once an alert is sent, we don't send another until a new
    order is filled or you change the threshold.

    - `type: "fixed" or "percentage"`

      How the value of a low-inventory threshold is interpreted.

      - `"fixed"`

      - `"percentage"`

    - `value: number`

      A whole number. For `fixed` this is an available quantity and must be 1
      or greater. For `percentage` this is a percentage of the quantity of the
      last filled order and must be between 1 and 100.

  - `metadata: optional map[unknown]`

    See the section on Metadata.

  - `rejectionReason: optional "content_overlapping_restricted_region" or "incomplete_image" or "internal_error"`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: optional string`

    A signed URL to the PDF of the custom envelope's artwork.

### Example

```http
curl https://api.postgrid.com/print-mail/v1/custom_envelopes \
    -H 'Content-Type: application/json' \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY" \
    -F envelopeType=standard_single_window \
    -F pdf=https://postgrid-public.s3.amazonaws.com/custom-envelope-artwork.pdf
```

#### Response

```json
{
  "id": "custom_envelope_sqF12lZ1VlBb",
  "available": 0,
  "createdAt": "2019-12-27T18:11:19.117Z",
  "live": true,
  "object": "custom_envelope",
  "status": "pending",
  "updatedAt": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "envelopeType": "standard_double_window",
  "lowInventoryThreshold": {
    "type": "fixed",
    "value": 1
  },
  "metadata": {
    "foo": "bar"
  },
  "rejectionReason": "content_overlapping_restricted_region",
  "url": "https://example.com"
}
```
