## Set Custom Envelope Low-Inventory Threshold

**post** `/print-mail/v1/custom_envelopes/{id}/threshold`

Sets the low-inventory threshold for the custom envelope by `id`,
replacing any threshold that was set before. When the available quantity
drops to or below the threshold, we send a low-inventory alert email to
the Admins of your organization.

### Path Parameters

- `id: string`

### Header Parameters

- `"idempotency-key": optional string`

### Body Parameters

- `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.

### 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/$ID/threshold \
    -H 'Content-Type: application/json' \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY" \
    -d '{
          "type": "fixed",
          "value": 1000
        }'
```

#### Response

```json
{
  "id": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
  "object": "custom_envelope",
  "live": false,
  "description": "Spring campaign envelope",
  "envelopeType": "standard_single_window",
  "available": 5000,
  "status": "approved",
  "url": "https://pg-prod-bucket-1.s3.amazonaws.com/test/custom_envelope_iPu6EaCbSUjZN7bEW8Qhee.pdf?AWSAccessKeyId=AKIA&Expires=1736870000&Signature=abc",
  "createdAt": "2021-12-16T03:06:17.419Z",
  "updatedAt": "2021-12-16T03:06:17.419Z",
  "lowInventoryThreshold": {
    "type": "fixed",
    "value": 1000
  }
}
```
