Skip to main content
Early access. This feature is in early access, which means it’s undergoing ongoing testing and development while we gather feedback, validate functionality, and improve outputs. Contact the C1 Support team if you’d like to try it out or share feedback.

SDK namespaces

The pre-authenticated sdk object provides type-safe access to the C1 API through 60+ namespaces organized by resource type.

Common SDK operations

Pagination

Use the pagination pattern to retrieve all results:

Importing external libraries

Dependency versions are pinned when you publish. To pick up newer versions, re-publish your function.
The runtime is Deno-based. Import npm packages using the npm: specifier:
Packages are resolved at deploy time. No package.json or node_modules needed. @c1/functions-sdk and @c1/test are pre-configured and available without the npm: prefix.

Configuration options

Configure secrets and network access in the C1 UI:
1
Navigate to Workflows > Functions.
2
Click on your function.
3
Click (the more actions menu) and select Edit config.
The config drawer has two sections: Secrets and Outbound network access. API access is configured separately by linking a service principal — see API access below.

Secrets

Store API keys and configuration values as key/value pairs. Secrets are encrypted at rest and decrypted at runtime. To access secrets in code:
functions.getConfig() returns { secrets: Record<string, string> }. Keys and values match what you defined in the UI.

Outbound network access

External domains must be added to the Outbound network access section in your function’s config or the request will be blocked. All outbound network traffic is routed through an egress proxy that enforces your allowlist.
Add allowed domains to your function’s config. This ensures functions can only communicate with endpoints you’ve explicitly approved, preventing unauthorized data exfiltration or unintended external calls. Here’s an example external API call:

API access

Functions authenticate to the C1 API as a linked service principal. The service principal’s role bindings determine what the function can do — every SDK call is authorized against those roles, and calls outside the granted permissions are denied. To link or change a function’s service principal, open the function and click > Link service principal. To change what the function can do, edit the service principal’s roles in Directory > Service principals — no function redeploy needed.
Functions created before this change were migrated automatically and linked to a service principal with read-only access. To grant write access, link the function to a service principal that holds write-capable roles.

Testing with @c1/test

New functions are scaffolded with a main.test.ts file alongside main.ts. The test file exports a registerTests function that receives your main function as handler, so each test can invoke it with different inputs.

Assertions

Each test() callback receives an assertion object with these methods:

Test options

Pass an options object as the third argument to test():

Running tests

Click Test draft when viewing a draft, or Run tests when viewing published code. Each test() call becomes an individual result in the test dialog, displayed with a pass/fail status chip. Click on a result to expand assertion details and logs.

Runtime constraints

Troubleshooting functions

Common issues and how to resolve them.

Function times out

  • Check for infinite loops
  • Verify external domains are in your allowlist
  • Break large operations into smaller batches

External API calls fail

  • Ensure domain is in the outbound network allowlist
  • Verify API credentials in secrets
  • Check console logs for detailed error messages

API returns 403 Forbidden

  • Check the linked service principal’s roles — the function authenticates as that SP, and the call is authorized against its role bindings
  • If the function isn’t linked to a service principal yet, link one (see API access)

Cannot deploy function

  • Verify you have admin access
  • Check for TypeScript syntax errors
  • Ensure all imports are valid