How to Create Namespaces to Organize DigitalOcean Functions

Functions are blocks of code that run on demand without the need to manage any infrastructure. Develop on your local machine, test your code from the command line (using doctl), then deploy to a production namespace or App Platform — no servers required.


Namespaces are a level of isolation and organization for functions and their settings. All functions and projects must be created in a namespace.

To create a new namespace, use the create subcommand of doctl serverless namespaces, passing in a namespace label (name) and datacenter region:

doctl serverless namespaces create --label "example-namespace" --region "nyc1"

The namespace is created and automatically connected to:

Connected to functions namespace 'fn-c92ea830-a657-43b0-96a2-9478ea730c44' on API host 'https://faas-nyc1-2ef2e6cc.doserverless.co'

The --label flag specifies a label (name) for the namespace. The --region flag indicates the region. For a list of valid regions, use the list-regions subcommand:

doctl serverless namespaces list-regions

This command prints a list of regions:

[ams ams3 blr blr1 fra fra1 lon lon1 nyc nyc1 sfo sfo3 sgp sgp1 tor tor1 syd1]

By default, doctl immediately connects to newly created namespaces. Use the -n or --no-connect flag to disable this.

To create a namespace from the DigitalOcean Control Panel, first click Functions in the left-hand menu to go to the Functions page.

If you have no namespaces, click the Create Function Namespace button to begin creating your first namespace. If you already have namespaces, click the Create Namespace button at the top of the Namespaces table.

Both links take you to the Create a Function Namespace page:

The Create a Function Namespace page, with options for datacenter region and label

Choose your datacenter region and namespace name, then click Create Namespace. When your new namespace is created, you’re taken to its overview page.