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

# Create a namespace

> Create a namespace. An organization can have at most five, `default` among them — a sixth returns `403`.



## OpenAPI

````yaml /openapi/source/external/agent-memory/agent-memory.json post /ai/memory/namespaces
openapi: 3.1.0
info:
  version: 1.0.0
  title: Telnyx API
  x-latency-category: interactive
  x-endpoint-cost: light
  description: >-
    Long-term memory for AI agents. A profile per user, caller, or agent: write
    memories in with `ingest` or `remember`, and recall them with `recall`.
    Facts are extracted, and contradictions resolve to the newest.
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Memory
    description: Write memories into a profile and recall them.
  - name: Profiles
    description: What a namespace and a profile hold.
  - name: Sources
    description: What a profile stored, and what its memories came from.
  - name: Operations
    description: Whether a write has finished.
  - name: Settings
    description: How a namespace's summaries are written.
paths:
  /ai/memory/namespaces:
    post:
      tags:
        - Namespaces
      summary: Create a namespace
      description: >-
        Create a namespace. An organization can have at most five, `default`
        among them — a sixth returns `403`.
      operationId: CreateNamespace
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NamespaceCreate'
            example:
              name: staging
      responses:
        '201':
          description: The created namespace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NamespaceResponse'
              example:
                data:
                  id: b3c17d90-2e4f-5a1b-9c8d-6f0a2b3c4d5e
                  name: staging
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10009'
                    title: Authentication failed
                    detail: Could not find any usable credentials in the request.
                    source:
                      pointer: /
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10009
        '403':
          description: Namespace limit reached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10039'
                    title: Forbidden
                    detail: >-
                      an organization can have 5 namespaces, `default` among
                      them, and this one already has that many
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10039
        '502':
          description: Upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: upstream_error
                    detail: the memory dataplane is unavailable
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const Namespace = await client.ai.memory.namespaces.create({
              name: 'name',
            });

            console.log(Namespace.data);
        - lang: Python
          source: |
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            namespace = client.ai.memory.namespaces.create(
                name="name",
            )
            print(namespace.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tnamespace, err := client.AI.Memory.Namespaces.New(\n\t\tcontext.TODO(),\n\t\ttelnyx.AIMemoryNamespaceNewParams{\n\t\t\tName: \"name\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", namespace.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.ai.memory.namespaces.NamespaceCreateParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    NamespaceCreateParams params = NamespaceCreateParams.builder()
                        .name("name")
                        .build();
                    var response = client.ai().memory().namespaces().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            namespace = telnyx.ai.memory.namespaces.create(name: "name")

            puts(namespace)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $namespace = $client->ai->memory->namespaces->create(
                name: 'name',
              );

              var_dump($namespace);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:memory:namespaces create \
              --api-key 'My API Key' \
              --name name
components:
  schemas:
    NamespaceCreate:
      properties:
        name:
          type: string
          title: Name
          description: A name for the new namespace, unique within your organization.
      type: object
      required:
        - name
      title: NamespaceCreate
    NamespaceResponse:
      properties:
        data:
          $ref: '#/components/schemas/Namespace'
      type: object
      required:
        - data
      title: NamespaceResponse
    TelnyxErrors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/TelnyxError'
    Namespace:
      properties:
        id:
          type: string
          title: Id
          description: The namespace's unique identifier.
        name:
          type: string
          title: Name
          description: >-
            The namespace's name, used in the path. `default` exists for every
            organization.
      type: object
      required:
        - id
        - name
      title: Namespace
      description: An isolated memory store within your organization.
    TelnyxError:
      type: object
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              type: string
        meta:
          type: object
          properties:
            url:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Telnyx API key

````