# Custom Envelopes

## Create Custom Envelope

`print_mail.custom_envelopes.create(CustomEnvelopeCreateParams**kwargs)  -> CustomEnvelope`

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

### Parameters

- `envelope_type: Literal["standard_double_window", "standard_single_window", "standard_large_window", 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: Union[str, FileTypes]`

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

  - `str`

  - `FileTypes`

    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[str]`

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

- `metadata: Optional[Dict[str, object]]`

  See the section on Metadata.

- `idempotency_key: Optional[str]`

### Returns

- `class CustomEnvelope: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_

  - `available: int`

    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.

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `live: bool`

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

  - `object: Literal["custom_envelope"]`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: Literal["pending", "approved", "rejected"]`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

  - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

      - `"fixed"`

      - `"percentage"`

    - `value: int`

      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[Dict[str, object]]`

    See the section on Metadata.

  - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: Optional[str]`

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

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope = client.print_mail.custom_envelopes.create(
    envelope_type="standard_single_window",
    pdf="https://postgrid-public.s3.amazonaws.com/custom-envelope-artwork.pdf",
    description="Spring campaign envelope",
)
print(custom_envelope.id)
```

#### 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"
}
```

## List Custom Envelopes

`print_mail.custom_envelopes.list(CustomEnvelopeListParams**kwargs)  -> SyncSkipLimit[CustomEnvelope]`

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

Gets a list of custom envelopes for the user.

### Parameters

- `limit: Optional[int]`

- `search: Optional[str]`

  You can supply any string to help narrow down the list of resources. For example, if you pass `"New York"` (quoted), it will return resources that have that string present somewhere in their response. Alternatively, you can supply a structured search query. See the documentation on `StructuredSearchQuery` for more details.

- `skip: Optional[int]`

### Returns

- `class CustomEnvelope: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_

  - `available: int`

    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.

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `live: bool`

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

  - `object: Literal["custom_envelope"]`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: Literal["pending", "approved", "rejected"]`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

  - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

      - `"fixed"`

      - `"percentage"`

    - `value: int`

      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[Dict[str, object]]`

    See the section on Metadata.

  - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: Optional[str]`

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

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
page = client.print_mail.custom_envelopes.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "object": "list",
  "limit": 10,
  "skip": 0,
  "totalCount": 1,
  "data": [
    {
      "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"
    }
  ]
}
```

## Get Custom Envelope

`print_mail.custom_envelopes.retrieve(strid)  -> CustomEnvelope`

**get** `/print-mail/v1/custom_envelopes/{id}`

Gets the information for a custom envelope by `id`. This should be a
unique identifying string starting with `custom_envelope_`.

### Parameters

- `id: str`

### Returns

- `class CustomEnvelope: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_

  - `available: int`

    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.

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `live: bool`

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

  - `object: Literal["custom_envelope"]`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: Literal["pending", "approved", "rejected"]`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

  - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

      - `"fixed"`

      - `"percentage"`

    - `value: int`

      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[Dict[str, object]]`

    See the section on Metadata.

  - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: Optional[str]`

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

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope = client.print_mail.custom_envelopes.retrieve(
    "id",
)
print(custom_envelope.id)
```

#### 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"
}
```

## Set Custom Envelope Low-Inventory Threshold

`print_mail.custom_envelopes.set_threshold(strid, CustomEnvelopeSetThresholdParams**kwargs)  -> CustomEnvelope`

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

### Parameters

- `id: str`

- `type: Literal["fixed", "percentage"]`

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

  - `"fixed"`

  - `"percentage"`

- `value: int`

  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.

- `idempotency_key: Optional[str]`

### Returns

- `class CustomEnvelope: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_

  - `available: int`

    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.

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `live: bool`

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

  - `object: Literal["custom_envelope"]`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: Literal["pending", "approved", "rejected"]`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

  - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

      - `"fixed"`

      - `"percentage"`

    - `value: int`

      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[Dict[str, object]]`

    See the section on Metadata.

  - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: Optional[str]`

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

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope = client.print_mail.custom_envelopes.set_threshold(
    id="id",
    type="fixed",
    value=1000,
)
print(custom_envelope.id)
```

#### 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
  }
}
```

## Clear Custom Envelope Low-Inventory Threshold

`print_mail.custom_envelopes.clear_threshold(strid, CustomEnvelopeClearThresholdParams**kwargs)  -> CustomEnvelope`

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

Clears the low-inventory threshold for the custom envelope by `id`. We
stop sending low-inventory alerts for the custom envelope.

### Parameters

- `id: str`

- `idempotency_key: Optional[str]`

### Returns

- `class CustomEnvelope: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_

  - `available: int`

    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.

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `live: bool`

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

  - `object: Literal["custom_envelope"]`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: Literal["pending", "approved", "rejected"]`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

  - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

      - `"fixed"`

      - `"percentage"`

    - `value: int`

      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[Dict[str, object]]`

    See the section on Metadata.

  - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: Optional[str]`

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

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope = client.print_mail.custom_envelopes.clear_threshold(
    id="id",
)
print(custom_envelope.id)
```

#### 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"
}
```

## Domain Types

### Custom Envelope

- `class CustomEnvelope: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_

  - `available: int`

    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.

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `live: bool`

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

  - `object: Literal["custom_envelope"]`

    Always `custom_envelope`.

    - `"custom_envelope"`

  - `status: Literal["pending", "approved", "rejected"]`

    The review status of a custom envelope's artwork.

    - `"pending"`

    - `"approved"`

    - `"rejected"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

  - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

      - `"fixed"`

      - `"percentage"`

    - `value: int`

      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[Dict[str, object]]`

    See the section on Metadata.

  - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

    Why the artwork of a custom envelope was rejected.

    - `"content_overlapping_restricted_region"`

    - `"incomplete_image"`

    - `"internal_error"`

  - `url: Optional[str]`

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

### Custom Envelope Low Inventory Threshold

- `class 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: Literal["fixed", "percentage"]`

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

    - `"fixed"`

    - `"percentage"`

  - `value: int`

    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.

# Orders

## Create Custom Envelope Order

`print_mail.custom_envelopes.orders.create(strid, OrderCreateParams**kwargs)  -> CustomEnvelopeOrder`

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

Creates a batch order of custom envelopes. The minimum order quantity is
5000.

### Parameters

- `id: str`

- `quantity_ordered: int`

  The quantity of custom envelopes ordered. Minimum 5000.

- `description: Optional[str]`

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

- `metadata: Optional[Dict[str, object]]`

  See the section on Metadata.

- `idempotency_key: Optional[str]`

### Returns

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope_order = client.print_mail.custom_envelopes.orders.create(
    id="id",
    quantity_ordered=5000,
    description="A batch of 5000",
)
print(custom_envelope_order.id)
```

#### Response

```json
{
  "id": "custom_envelope_order_6qZ2LHGvyYh4h6Ud1uUctT",
  "object": "custom_envelope_order",
  "live": false,
  "customEnvelope": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
  "quantityOrdered": 5000,
  "status": "placed",
  "createdAt": "2021-12-16T03:23:22.617Z",
  "updatedAt": "2021-12-16T03:23:22.617Z"
}
```

## List Custom Envelope Orders

`print_mail.custom_envelopes.orders.list(strid, OrderListParams**kwargs)  -> SyncSkipLimit[CustomEnvelopeOrder]`

**get** `/print-mail/v1/custom_envelopes/{id}/orders`

Gets a list of orders for the custom envelope by `id`.

### Parameters

- `id: str`

- `limit: Optional[int]`

- `search: Optional[str]`

  You can supply any string to help narrow down the list of resources. For example, if you pass `"New York"` (quoted), it will return resources that have that string present somewhere in their response. Alternatively, you can supply a structured search query. See the documentation on `StructuredSearchQuery` for more details.

- `skip: Optional[int]`

### Returns

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
page = client.print_mail.custom_envelopes.orders.list(
    id="id",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "object": "list",
  "limit": 10,
  "skip": 0,
  "totalCount": 1,
  "data": [
    {
      "id": "custom_envelope_order_6qZ2LHGvyYh4h6Ud1uUctT",
      "object": "custom_envelope_order",
      "live": false,
      "customEnvelope": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
      "quantityOrdered": 5000,
      "status": "placed",
      "createdAt": "2021-12-16T03:23:22.617Z",
      "updatedAt": "2021-12-16T03:23:22.617Z"
    }
  ]
}
```

## Get Custom Envelope Order

`print_mail.custom_envelopes.orders.retrieve(strorder_id, OrderRetrieveParams**kwargs)  -> CustomEnvelopeOrder`

**get** `/print-mail/v1/custom_envelopes/{id}/orders/{orderID}`

Gets a specific custom envelope order by custom envelope ID as `id` and
custom envelope order ID as `orderID`.

### Parameters

- `id: str`

- `order_id: str`

- `expand: Optional[List[Literal["customEnvelope"]]]`

  Pass `expand[]=customEnvelope` to expand the order's
  `customEnvelope` field into the full custom envelope object.

  - `"customEnvelope"`

### Returns

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope_order = client.print_mail.custom_envelopes.orders.retrieve(
    order_id="orderID",
    id="id",
)
print(custom_envelope_order.id)
```

#### Response

```json
{
  "id": "custom_envelope_order_6qZ2LHGvyYh4h6Ud1uUctT",
  "object": "custom_envelope_order",
  "live": false,
  "customEnvelope": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
  "quantityOrdered": 5000,
  "status": "placed",
  "createdAt": "2021-12-16T03:23:22.617Z",
  "updatedAt": "2021-12-16T03:23:22.617Z"
}
```

## Progress Test Custom Envelope Order

`print_mail.custom_envelopes.orders.progress(strorder_id, OrderProgressParams**kwargs)  -> CustomEnvelopeOrder`

**post** `/print-mail/v1/custom_envelopes/{id}/orders/{orderID}/progress`

Moves the custom envelope order by `orderID` for the custom envelope by
`id` from `placed` to `in_progress`. This is only available in test mode
and can be used to simulate how a live order would be produced.

Note: this will fail with a
`custom_envelope_order_progress_failed_error` if the order's status is
not `placed`.

### Parameters

- `id: str`

- `order_id: str`

### Returns

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope_order = client.print_mail.custom_envelopes.orders.progress(
    order_id="orderID",
    id="id",
)
print(custom_envelope_order.id)
```

#### Response

```json
{
  "id": "custom_envelope_order_6qZ2LHGvyYh4h6Ud1uUctT",
  "object": "custom_envelope_order",
  "live": false,
  "customEnvelope": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
  "quantityOrdered": 5000,
  "status": "in_progress",
  "createdAt": "2021-12-16T03:23:22.617Z",
  "updatedAt": "2021-12-16T03:23:22.617Z"
}
```

## Fill Test Custom Envelope Order

`print_mail.custom_envelopes.orders.fill(strorder_id, OrderFillParams**kwargs)  -> CustomEnvelopeOrder`

**post** `/print-mail/v1/custom_envelopes/{id}/orders/{orderID}/fills`

Fills the custom envelope order by `orderID` for the custom envelope by
`id`. This is only available in test mode and can be used to simulate
how a live order would be filled.

Note: this will fail with a `custom_envelope_order_fill_failed_error` if
the order's status is not `in_progress`, and with a
`custom_envelope_order_fill_not_approved_error` if the custom envelope
has not been approved.

### Parameters

- `id: str`

- `order_id: str`

- `expand: Optional[List[Literal["customEnvelope"]]]`

  Pass `expand[]=customEnvelope` to expand the order's
  `customEnvelope` field into the full custom envelope object.

  - `"customEnvelope"`

### Returns

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope_order = client.print_mail.custom_envelopes.orders.fill(
    order_id="orderID",
    id="id",
)
print(custom_envelope_order.id)
```

#### Response

```json
{
  "id": "custom_envelope_order_6qZ2LHGvyYh4h6Ud1uUctT",
  "object": "custom_envelope_order",
  "live": false,
  "customEnvelope": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
  "quantityOrdered": 5000,
  "status": "filled",
  "createdAt": "2021-12-16T03:23:22.617Z",
  "updatedAt": "2021-12-16T03:23:22.617Z",
  "quantityFilled": 5000
}
```

## Cancel Custom Envelope Order

`print_mail.custom_envelopes.orders.cancel(strorder_id, OrderCancelParams**kwargs)  -> CustomEnvelopeOrder`

**delete** `/print-mail/v1/custom_envelopes/{id}/orders/{orderID}`

Cancels the custom envelope order by `orderID` for the custom envelope
by `id`. Only orders whose status is `placed` can be cancelled. Note that
this operation cannot be undone.

### Parameters

- `id: str`

- `order_id: str`

- `expand: Optional[List[Literal["customEnvelope"]]]`

  Pass `expand[]=customEnvelope` to expand the order's
  `customEnvelope` field into the full custom envelope object.

  - `"customEnvelope"`

### Returns

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
custom_envelope_order = client.print_mail.custom_envelopes.orders.cancel(
    order_id="orderID",
    id="id",
)
print(custom_envelope_order.id)
```

#### Response

```json
{
  "id": "custom_envelope_order_6qZ2LHGvyYh4h6Ud1uUctT",
  "object": "custom_envelope_order",
  "live": false,
  "customEnvelope": "custom_envelope_iPu6EaCbSUjZN7bEW8Qhee",
  "quantityOrdered": 5000,
  "status": "cancelled",
  "createdAt": "2021-12-16T03:23:22.617Z",
  "updatedAt": "2021-12-16T03:23:22.617Z"
}
```

## Domain Types

### Custom Envelope Order

- `class CustomEnvelopeOrder: …`

  - `id: str`

    A unique ID prefixed with custom_envelope_order_

  - `created_at: datetime`

    The UTC time at which this resource was created.

  - `custom_envelope: CustomEnvelope`

    The ID of the custom envelope that this order replenishes. Expanded into
    the full custom envelope object on the individual order retrieval, fill
    and cancellation endpoints when `expand[]=customEnvelope` is supplied.

    - `str`

    - `class CustomEnvelope: …`

      - `id: str`

        A unique ID prefixed with custom_envelope_

      - `available: int`

        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.

      - `created_at: datetime`

        The UTC time at which this resource was created.

      - `live: bool`

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

      - `object: Literal["custom_envelope"]`

        Always `custom_envelope`.

        - `"custom_envelope"`

      - `status: Literal["pending", "approved", "rejected"]`

        The review status of a custom envelope's artwork.

        - `"pending"`

        - `"approved"`

        - `"rejected"`

      - `updated_at: datetime`

        The UTC time at which this resource was last updated.

      - `description: Optional[str]`

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

      - `envelope_type: Optional[Literal["standard_double_window", "standard_single_window", "standard_large_window", 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"`

      - `low_inventory_threshold: 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: Literal["fixed", "percentage"]`

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

          - `"fixed"`

          - `"percentage"`

        - `value: int`

          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[Dict[str, object]]`

        See the section on Metadata.

      - `rejection_reason: Optional[Literal["content_overlapping_restricted_region", "incomplete_image", "internal_error"]]`

        Why the artwork of a custom envelope was rejected.

        - `"content_overlapping_restricted_region"`

        - `"incomplete_image"`

        - `"internal_error"`

      - `url: Optional[str]`

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

  - `live: bool`

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

  - `object: Literal["custom_envelope_order"]`

    Always `custom_envelope_order`.

    - `"custom_envelope_order"`

  - `quantity_ordered: int`

    The quantity of custom envelopes ordered. Minimum 5000.

  - `status: Literal["placed", "in_progress", "filled", "cancelled"]`

    The status of a custom envelope order.

    - `"placed"`

    - `"in_progress"`

    - `"filled"`

    - `"cancelled"`

  - `updated_at: datetime`

    The UTC time at which this resource was last updated.

  - `description: Optional[str]`

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

  - `metadata: Optional[Dict[str, object]]`

    See the section on Metadata.

  - `quantity_filled: Optional[int]`

    The quantity of custom envelopes that were filled for this order. Only
    returned once the order's status is `filled`.
