---
title: "Create a Code Container"
method: POST
path: "/code_containers"
tags: ["Code Containers"]
---

# Create a Code Container

`POST /code_containers`

## Request

- Base URL: `https://dataops.nexla.io/nexla-api`
- URL: `https://dataops.nexla.io/nexla-api/code_containers`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/nexla/apis/nexla-rest-api/docs/code_containers/post.ts> (a function with typed inputs; its response is checked against the schema)

Use this endpoint to create a new code container.

## Request body

- CodeContainerMutable
  - `name` string, required
  - `description` string
  - `data_credentials_id` integer: Credential ID for accessing the code repository (e.g., Github). This is for code containers in which the code is saved in a remote repository. Note that this is not required for script connectors in which the script is hosted in a Nexla Github repository.
  - `resource_type` 'transform' | 'ai_function' | 'source' | 'sink' | 'error' | 'validator': The type of resource that this code container is to be used for. - `transform`: For user defined code that is used in a Nexset transform. - `ai_function`: For user defined code that is used in an AI function. See `ai_function_type` for the scenarios where this is used. - `source`: For user defined code in a source. - `sink`: For user defined code in a sink. - `error`: For user defined code that acts as an error handler. - `validator`: For user defined code that acts as a validator.
  - `ai_function_type` 'chunker' | 'context_enricher' | 'query_rewriter' | 'reranker': The type of AI function that this code container is used for. - `chunker`: Used to chunk parsed file content into smaller chunks in a Document Ingestion flow. - `context_enricher`: Used to enrich the context of a query in a RAG flow. - `query_rewriter`: Used to rewrite a query in a RAG flow. - `reranker`: Used to rerank a list of results in a RAG flow.
  - `output_type` 'record' | 'attribute' | 'custom', required: The type of output that this code container produces. - `record`: Produces a full Nexset record. Used only when the code container is used to modify a Nexset, i.e output_type: `transform` - `attribute`: Produces value for an attribute inside a Nexset record. Used only when the code container is used to modify a value inside a Nexset, i.e output_type: `transform` - `custom`: Produces custom output. Used as a catch-all output format when a code container is used in any context other than for Nexset modification.
  - `code_type` 'jolt_standard' | 'jolt_custom' | 'python' | 'python3' | 'javascript', required
  - `code_encoding` 'none' | 'base64', required: Whether or not the code in the `code` block is encoded. Set this to `none` for reusable record transforms.
  - `code` union, required: Code to be executed in this code container. Please refer to the endpoints for `transforms`, `attribute_transforms` and `validators` for respective `code` block requirements.
    - string
    - object[]
      - `operation` string
      - `spec` object
        - `language` string
        - `encoding` string
        - `script` string
  - `reusable` boolean, required: Whether or not this transform can be referenced by multiple resources. This should always be `true` for reusable record and attribute transforms.
  - `tags` string[]
  - `custom_config` object

## Response `200`

Success

- CodeContainer
  - `id` integer
  - `name` string
  - `resource_type` 'transform' | 'ai_function' | 'source' | 'sink' | 'error' | 'validator': The type of resource that this code container is to be used for. - `transform`: For user defined code that is used in a Nexset transform. - `ai_function`: For user defined code that is used in an AI function. See `ai_function_type` for the scenarios where this is used. - `source`: For user defined code in a source. - `sink`: For user defined code in a sink. - `error`: For user defined code that acts as an error handler. - `validator`: For user defined code that acts as a validator.
  - `ai_function_type` 'chunker' | 'context_enricher' | 'query_rewriter' | 'reranker': The type of AI function that this code container is used for. - `chunker`: Used to chunk parsed file content into smaller chunks in a Document Ingestion flow. - `context_enricher`: Used to enrich the context of a query in a RAG flow. - `query_rewriter`: Used to rewrite a query in a RAG flow. - `reranker`: Used to rerank a list of results in a RAG flow.
  - `reusable` boolean
  - `public` boolean
  - `owner` UserSimplified
    - `id` integer
    - `full_name` string
    - `email` string
    - `email_verified_at` string, date-time
  - `org` OrgSimplified
    - `id` integer
    - `name` string
    - `email_domain` string
    - `email` string
    - `client_identifier` string
    - `org_webhook_host` string
  - `access_roles` string[]: This property reflects all the permissions the user/team/organization has to this resource. 1. `collaborator`: The user/team/organization can view the resource but not make any modifications to it. 2. `operator`: The user/team/organization can view the resource and can activate/pause it, but not make any other modifications to it. 3. `administrator`: The user/team/organization has complete administrative rights to this resource. 4. `owner`: This user created the resource and so has complete administrative rights to it.
  - `data_credentials` object
    - `id` integer
    - `name` string
    - `description` string
    - `updated_at` string, date-time
    - `created_at` string, date-time
  - `runtime_data_credentials` object
    - `id` integer
    - `name` string
    - `description` string
    - `updated_at` string, date-time
    - `created_at` string, date-time
  - `description` string
  - `code_type` 'jolt_standard' | 'jolt_custom' | 'python' | 'python3' | 'javascript'
  - `output_type` 'record' | 'attribute' | 'custom': The type of output that this code container produces. - `record`: Produces a full Nexset record. Used only when the code container is used to modify a Nexset, i.e output_type: `transform` - `attribute`: Produces value for an attribute inside a Nexset record. Used only when the code container is used to modify a value inside a Nexset, i.e output_type: `transform` - `custom`: Produces custom output. Used as a catch-all output format when a code container is used in any context other than for Nexset modification.
  - `code_config` object
  - `custom_config` object
  - `code_encoding` string
  - `code` object[]
    - `operation` string
    - `spec` object
      - `language` string
      - `encoding` string
      - `script` string
  - `managed` boolean
  - `data_sets` integer[]
  - `copied_from_id` integer
  - `updated_at` string, date-time
  - `created_at` string, date-time
  - `tags` string[]

## Other responses

- `401`: Unauthorized
- `403`: Forbidden

---

[API](https://skmtc.dev/nexla/apis/nexla-rest-api.md) - [All operations](https://skmtc.dev/nexla/apis/nexla-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nexla/apis/nexla-rest-api/revisions/ef02be92fe7b?raw)
