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

# createContract

> Create a contract for a customer together with all of its (custom) subscriptions in a single atomic operation. Every subscription is created inside one transaction — any validation or creation failure rolls the whole contract back. Returns the customer's contract from the connected billing provider (Received).



**mutation** `createContract(input: CreateContractInput!): ContractDTO!`

## Arguments

**`input`**: `CreateContractInput!` (required)

Input for creating a contract and its subscriptions atomically.

## Returns

`ContractDTO!`

**`activationEndDate`**: `DateTime`

Activation end date (ISO 8601)

---

**`activationStartDate`**: `DateTime`

Activation start date (ISO 8601)

---

**`billingId`**: `String`

The billing provider (Received) contract ID; null until the contract has synced to the billing provider

---

**`billingState`**: `ContractState`

Contract state

---

**`contractId`**: `String!`

The Stigg contract ref ID (the key used to fetch/update/delete this contract)

---

**`createdAt`**: `DateTime`

Timestamp of creation (ISO 8601)

---

**`customerExternalId`**: `String`

External ID of the customer the contract belongs to (the Stigg customer ref ID)

---

**`externalId`**: `String!`

External ID for the contract: the metering provider externalId when one is mapped, otherwise the contract ID.

---

**`id`**: `String`

The persisted Stigg contract id (matches Subscription.contractId; present for Stigg-managed contracts)

---

**`latestInvoice`**: `SubscriptionInvoice`

The most recent non-draft invoice for this contract (open, paid, or canceled), when one exists

---

**`name`**: `String`

Contract name

---

**`nextInvoice`**: `ContractNextInvoiceDTO`

Preview of the contract's next (upcoming) invoice, when the contract has one

---

**`poNumber`**: `String`

Purchase-order number, when set on the contract

---

**`refId`**: `String`

The Stigg contract ref ID (present for Stigg-managed contracts; the key used to update/delete)

---

**`state`**: `ContractState!`

Contract state

---

**`subscriptions`**: `[ContractSubscriptionRef!]!`

Custom subscriptions attached to this contract (empty when none)

## Examples

```graphql Mutation
mutation CreateContract($input: CreateContractInput!) {
  createContract(input: $input) {
    activationEndDate
    activationStartDate
    billingId
    billingState
    contractId
    createdAt
  }
}
```

```json Variables
{
  "input": {
    "customerId": "string",
    "subscriptions": [
      {}
    ]
  }
}
```

```json Response
{
  "data": {
    "createContract": {
      "activationEndDate": "value",
      "activationStartDate": "value",
      "billingId": "string",
      "billingState": "ACTIVE",
      "contractId": "string",
      "createdAt": "value"
    }
  }
}
```


## Related topics

- [Create contract](https://docs.stigg.io/api-reference/contracts/create-contract.md)
- [CreateContractInput](https://docs.stigg.io/graphql-reference/types/CreateContractInput.md)
- [Setting up a contract](https://docs.stigg.io/documentation/managing-customers-and-subscriptions/contracts/setup-flow.md)
- [Create product](https://docs.stigg.io/api-reference/products/create-product.md)
- [Create an addon](https://docs.stigg.io/api-reference/addons/create-an-addon.md)


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