# Create deployment

Source: https://docs.orbytelabs.com/api-reference/deployments/createDeployment

## POST /v1/deployments

```json
{
  "operationId": "createDeployment",
  "tags": [
    "Deployments"
  ],
  "summary": "Deploy plans and features",
  "description": "Creates one immutable snapshot in the authorized environment. Optional grantPolicies maps policy keys to definitions with on: customer.created and positive credits. Plan and policy grants can fund any deployed feature by default, including features added later. Add featureKeys to restrict access to specific features. Listed keys must be unique and belong to the catalog. An empty list is valid only on plans and grants no feature access. Each policy issues a separate grant once when the customer is created. Policy grants require no subscription or payment and have zero paid value. Optional expiresAfterDays sets a positive whole-day lifetime starting at customer creation; omit it for no expiry. Policy changes apply to customers created after the change. Stripe publishing runs asynchronously; poll getDeployment until ready or failed.",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "schema": {
        "type": "string",
        "minLength": 1,
        "description": "Required for environment-scoped OAuth operations. API keys remain bound to their own environment."
      },
      "required": false,
      "description": "Required for environment-scoped OAuth operations. API keys remain bound to their own environment.",
      "name": "X-Orbyte-Environment",
      "in": "header"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "properties": {
            "features": {
              "default": {},
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "^[a-z][a-z0-9_-]*$"
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 128
                  },
                  "aggregation": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "sum"
                          },
                          "field": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "count"
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "distinct"
                          },
                          "by": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "window": {
                            "type": "object",
                            "properties": {
                              "value": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 9999
                              },
                              "unit": {
                                "type": "string",
                                "enum": [
                                  "minute",
                                  "hour",
                                  "day",
                                  "week",
                                  "month"
                                ]
                              }
                            },
                            "required": [
                              "value",
                              "unit"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "cost": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "fixed"
                          },
                          "amount": {
                            "type": "string",
                            "pattern": "^-?(0|[1-9][0-9]*)$",
                            "maxLength": 20
                          },
                          "perUnit": {
                            "default": 1,
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "type",
                          "amount"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "percentage"
                          },
                          "percentageBps": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 10000
                          }
                        },
                        "required": [
                          "type",
                          "percentageBps"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "markup"
                          },
                          "markupBps": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "type",
                          "markupBps"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "aggregation",
                  "cost"
                ],
                "additionalProperties": false
              }
            },
            "plans": {
              "default": {},
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "^[a-z][a-z0-9_-]*$"
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 128
                  },
                  "costUsdInNanos": {
                    "type": "string",
                    "pattern": "^-?(0|[1-9][0-9]*)$",
                    "maxLength": 20
                  },
                  "trialDays": {
                    "default": 0,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "creditGrant": {
                    "type": "string",
                    "pattern": "^-?(0|[1-9][0-9]*)$",
                    "maxLength": 20
                  },
                  "rollover": {
                    "type": "object",
                    "properties": {
                      "maxCredits": {
                        "type": "string",
                        "pattern": "^-?(0|[1-9][0-9]*)$",
                        "maxLength": 20
                      },
                      "maxPercentage": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100,
                        "description": "Maximum rollover as a percentage of the period's credit grant."
                      },
                      "expiresAfterDays": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991,
                        "description": "Extra days after the paid billing period ends."
                      }
                    },
                    "required": [
                      "expiresAfterDays"
                    ]
                  },
                  "period": {
                    "type": "object",
                    "properties": {
                      "interval": {
                        "default": "MONTHLY",
                        "type": "string",
                        "enum": [
                          "YEARLY",
                          "MONTHLY",
                          "WEEKLY",
                          "DAILY"
                        ]
                      },
                      "intervalCount": {
                        "default": 1,
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      }
                    }
                  },
                  "featureKeys": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128,
                      "pattern": "^[a-z][a-z0-9_-]*$"
                    }
                  }
                },
                "required": [
                  "name",
                  "costUsdInNanos",
                  "creditGrant",
                  "period"
                ]
              }
            },
            "grantPolicies": {
              "type": "object",
              "propertyNames": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "^[a-z][a-z0-9_-]*$"
              },
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "on": {
                    "anyOf": [
                      {
                        "type": "string",
                        "const": "customer.created"
                      }
                    ]
                  },
                  "credits": {
                    "type": "string",
                    "pattern": "^-?(0|[1-9][0-9]*)$",
                    "maxLength": 20
                  },
                  "expiresAfterDays": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "featureKeys": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128,
                      "pattern": "^[a-z][a-z0-9_-]*$"
                    }
                  }
                },
                "required": [
                  "on",
                  "credits"
                ]
              }
            }
          },
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "202": {
      "description": "Deployment ID; queued for Stripe sync",
      "content": {
        "application/json": {
          "schema": {
            "type": "string",
            "$schema": "https://json-schema.org/draft/2020-12/schema"
          }
        }
      }
    },
    "400": {
      "description": "Invalid request",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "401": {
      "description": "Unauthorized",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "403": {
      "description": "Insufficient permission",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "404": {
      "description": "Resource not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "409": {
      "description": "Resource or request conflict",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "413": {
      "description": "Content too large",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "415": {
      "description": "Unsupported media type",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "500": {
      "description": "Unexpected server error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    }
  }
}
```

Complete schema: [OpenAPI 3.1 document](https://docs.orbytelabs.com/openapi.json)