All Products
Search
Document Center

Function Compute:Custom Domains for FC Agent Sandbox

Last Updated:Jul 14, 2026

If you want to access FC Agent Sandbox through a fixed domain name in production, or use your own certificate for web services running inside a sandbox, you can bind a custom domain to FC Agent Sandbox.

After a custom domain is bound, you can use:

  • A control-plane domain to access FC Agent Sandbox APIs, for example https://api.example.com.

  • A data-plane domain to access services inside a sandbox, for example https://{port}-{sandboxId}.example.com.

Using example.com as an example:

PurposeExampleDescription
Control-plane domainapi.example.comUsed for API requests such as creating, querying, and deleting FC Agent Sandbox instances.
Data-plane domain*.example.comUsed to access services exposed on specific ports inside a sandbox.
SDK apiUrlhttps://api.example.comThe endpoint used by the SDK to access FC Agent Sandbox APIs.
SDK domainexample.comThe base domain used by the SDK to construct sandbox service addresses.

Limits

  • When you bind a custom domain to FC Agent Sandbox, you must select the same region where the sandbox is deployed.

  • The control-plane domain currently supports only a single domain name prefixed with api., such as api.example.com.

  • The data-plane domain is the wildcard domain obtained by removing the api. prefix from the control-plane domain, for example *.example.com.

  • Only HTTPS is supported.

  • You must upload a certificate that covers the data-plane wildcard domain, such as *.example.com. A single-domain certificate that only covers api.example.com is not sufficient.

  • The private key must be an unencrypted RSA PEM key. If your private key is in the -----BEGIN PRIVATE KEY----- format, convert it to -----BEGIN RSA PRIVATE KEY----- first.

  • Internationalized domain names are not supported.

  • By default, one primary account can bind up to 5 FC Agent Sandbox custom domains. Contact support if you need a higher quota.

  • Your custom domain must complete ICP filing or filing access as required by the console validation result.

Example of converting the private key format:

openssl rsa -in pkcs8.key -out pkcs1.key

1. Add a custom domain

  1. Sign in to the Function Compute FC Agent Sandbox console.

  2. In the left-side navigation pane, choose FC Agent Sandbox > Domain Management.

  3. Select the region where your FC Agent Sandbox instances are deployed.

  4. Click Add Custom Domain.

  5. On the Add Custom Domain page, enter the control-plane domain, for example api.example.com.

  6. Follow the prompts to obtain the control-plane CNAME and data-plane CNAME for DNS configuration in the next step.

Important: The custom domain must use the same region as FC Agent Sandbox. Otherwise DNS resolution and certificate validation may fail.

2. Configure DNS resolution

Sign in to the Alibaba Cloud DNS console and point your custom domain to the CNAME records provided by FC Agent Sandbox.

CNAME typeHost recordRecord typeExample record value
Control-plane CNAMEapiCNAMEapi.cn-beijing.e2b.fc.aliyuncs.com
Data-plane CNAME*CNAME{AccountID}.cn-beijing.e2b.fc.aliyuncs.com

Example: if your primary account ID is 119085698835**** and your FC Agent Sandbox region is China North 2 (Beijing), the data-plane CNAME can be configured as:

119085698835****.cn-beijing.e2b.fc.aliyuncs.com

After the configuration is complete, wait for DNS propagation before you submit or verify the domain. You can use the following commands to check the resolution result:

dig +short CNAME api.example.com
dig +short CNAME test.example.com

Here, test.example.com is used to verify whether the wildcard resolution for *.example.com has taken effect.

3. Configure an HTTPS certificate

FC Agent Sandbox custom domains always use HTTPS. Upload the certificate and private key when you add the domain.

SettingDescription
Certificate nameUsed to identify the uploaded certificate.
PEM certificate contentEnter the full certificate chain, including -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----.
PEM private keyEnter the unencrypted RSA private key, including -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----.
TLS protocol versionTLS 1.2 or later is recommended.

Certificate requirements:

  • The certificate must be valid.

  • The certificate and private key must match.

  • The certificate must cover the data-plane wildcard domain. For example, if the control-plane domain is api.example.com, the certificate must cover *.example.com.

4. Use a custom domain in the SDK

After the domain is added successfully, replace the API endpoint and data-plane base domain in the SDK with the custom domain that you bound.

TypeScript example:

import { Sandbox } from "e2b";

const sandbox = await Sandbox.create("code-interpreter-v1", {
  apiKey: process.env.E2B_API_KEY,
  apiUrl: "https://api.example.com",
  domain: "example.com",
});

const host = sandbox.getHost(8000);
console.log(`https://${host}`);

Python example:

from e2b import Sandbox

sandbox = Sandbox.create(
    template="code-interpreter-v1",
    api_key=os.environ["E2B_API_KEY"],
    api_url="https://api.example.com",
    domain="example.com",
)

host = sandbox.get_host(8000)
print(f"https://{host}")

If the sandbox ID is sandbox-id and the exposed port is 8000, the SDK returns an address in the following format:

https://8000-sandbox-id.example.com

5. Verify the custom domain

After the configuration is complete, verify it by following these steps:

  1. Use the SDK or OpenAPI to create an FC Agent Sandbox instance.

  2. Start an HTTP service inside the sandbox, for example on port 8000.

  3. Call sandbox.getHost(8000) to get the access domain.

  4. Use a browser or curl to access https://{port}-{sandboxId}.example.com.

Example:

curl -v https://8000-sandbox-id.example.com

If you receive a response from the service running inside the sandbox, the data-plane domain is working.

FAQ

IssuePossible causeResolution
CNAME validation fails when you add the domainDNS is not configured, the record value is incorrect, or DNS propagation is not completeVerify that the control-plane CNAME points to the target shown in the console, then retry after DNS propagation completes.
The certificate does not match during HTTPS accessThe certificate does not cover the data-plane wildcard domainUpload a wildcard certificate that covers *.example.com.
The private key format is invalidThe private key is not an unencrypted RSA PEM keyConvert it with openssl rsa -in pkcs8.key -out pkcs1.key and upload it again.
The SDK still returns the default domainapiUrl or domain is not configured in the SDKSet apiUrl to the control-plane domain and domain to the data-plane base domain.
The data-plane address cannot be accessedThe wildcard CNAME is not effective, or the service inside the sandbox is not listening on the target portCheck the *.example.com resolution result and confirm that the service inside the sandbox is running.
The domain quota is reachedMultiple custom domains are already bound under the current primary accountDelete unused domains or contact support to increase the quota.

Notes

  • sandbox.getHost(port) returns only the host name. In most cases, you need to prepend https:// when accessing it.

  • Custom domains are suitable for production or long-lived access scenarios. For temporary debugging, you can still use the default FC Agent Sandbox domain.

  • Do not expose sensitive data, internal debugging endpoints, or long-lived credentials through unauthenticated port services.