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

# Create a function deployment

> Deploys a function to an existing integration. Use `type: function` to deploy submitted TypeScript
source code, or `type: template` to deploy a template from the provider catalog. Requires an API key with the
`environment:deploy` scope.


<Info>
  Requires an API key with the `environment:deploy` scope. [Learn more about API key scopes](/reference/backend/http-api/api-keys#scopes).
</Info>

Deploys a function to an existing integration: either submitted TypeScript source code (`type: function`) or a template from the provider catalog (`type: template`).


## OpenAPI

````yaml POST /functions/deployments
openapi: 3.1.0
info:
  title: Nango API
  description: Nango API specs used to authorize & sync data with external APIs.
  version: 1.0.0
servers:
  - url: https://api.nango.dev
    description: Production server
  - url: http://localhost:3003
    description: Local server
security:
  - bearerAuth: []
externalDocs:
  url: https://nango.dev/docs/reference/backend/http-api/authentication
paths:
  /functions/deployments:
    post:
      summary: Create a function deployment
      description: >
        Deploys a function to an existing integration. Use `type: function` to
        deploy submitted TypeScript

        source code, or `type: template` to deploy a template from the provider
        catalog. Requires an API key with the

        `environment:deploy` scope.
      operationId: createFunctionDeployment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FunctionDeploymentRequest'
      responses:
        '202':
          description: >
            Deployment record. `status` may be any of `waiting`, `running`,
            `success`, or `failed`. If it is not

            `success`, poll `GET /functions/deployments/{id}` for the final
            status and details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FunctionDeploymentResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            The template is already deployed, or the template name is ambiguous
            and `function_type` is required.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - template_already_deployed
                          - ambiguous_function
                      message:
                        type: string
        '500':
          $ref: '#/components/responses/ServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '504':
          $ref: '#/components/responses/GatewayTimeout'
components:
  schemas:
    FunctionDeploymentRequest:
      oneOf:
        - $ref: '#/components/schemas/FunctionDeploymentCodeRequest'
        - $ref: '#/components/schemas/FunctionDeploymentTemplateRequest'
      discriminator:
        propertyName: type
        mapping:
          function:
            $ref: '#/components/schemas/FunctionDeploymentCodeRequest'
          template:
            $ref: '#/components/schemas/FunctionDeploymentTemplateRequest'
    FunctionDeploymentResponse:
      type: object
      additionalProperties: false
      required:
        - id
        - status
        - created_at
      properties:
        id:
          type: string
        status:
          type: string
          enum:
            - waiting
            - running
            - success
            - failed
          description: >-
            The status of the function deployment. Poll `GET
            /functions/deployments/{id}` to get the final status.
        created_at:
          type: string
          format: date-time
    FunctionDeploymentCodeRequest:
      type: object
      additionalProperties: false
      required:
        - type
        - integration_id
        - function_name
        - function_type
        - code
      properties:
        type:
          type: string
          enum:
            - function
          description: Deploy submitted function source code.
        integration_id:
          type: string
          description: The integration ID (unique_key) that you created in Nango.
        function_name:
          type: string
          description: The sync or action function name.
        function_type:
          $ref: '#/components/schemas/RunnableFunctionType'
        code:
          type: string
          minLength: 1
          description: The TypeScript source code for the function.
        version:
          type: string
          description: Optional version tag for this deployment.
        allow_destructive:
          type: boolean
          description: >-
            Allow overwriting an existing standalone function with the same
            name.
    FunctionDeploymentTemplateRequest:
      type: object
      additionalProperties: false
      required:
        - type
        - integration_id
        - template
      properties:
        type:
          type: string
          enum:
            - template
          description: Deploy a template from the provider catalog onto the integration.
        integration_id:
          type: string
          description: The integration ID (unique_key) that you created in Nango.
        template:
          type: string
          description: >-
            The template name to deploy, as listed by `GET
            /providers/{provider}/templates`.
        function_type:
          $ref: '#/components/schemas/RunnableFunctionType'
    StdError:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - code
          properties:
            code:
              type: string
            message:
              type: string
            errors:
              type: array
              items:
                type: object
    RunnableFunctionType:
      type: string
      enum:
        - action
        - sync
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    ServerError:
      description: Server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    ServiceUnavailable:
      description: Service unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    GatewayTimeout:
      description: Gateway timeout
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: The secret key from your Nango environment.

````