Projects & Deploy

Create projects, execute code in sandboxes, and deploy to production

Overview

Projects are the top-level container for your applications. Each project can have sandboxes for development, databases, storage buckets, and production deployments.

All project methods are available on r.projects.

Methods

MethodDescription
list(params?)List projects accessible to the authenticated user.
get(id)Get a project by ID with full details (sandbox, databases, storage).
create(input)Create a new project in an organization.
delete(id)Delete a project permanently.
deploy(id, input?)Trigger a deployment (production or preview).
deployments(id, params?)List all deployments for a project.
deployment(projectId, deploymentId)Get a specific deployment by ID.
deploymentLogs(projectId, deploymentId, params?)Get build/runtime logs for a deployment.
executeCode(id, input)Execute code in the project’s sandbox.
sandbox(id)Get the current sandbox status.
createSandbox(id)Start a new sandbox for the project.
stopSandbox(id)Stop and clean up the project’s sandbox.

List projects

1const { data: projects, meta } = await r.projects.list();
2
3for (const project of projects) {
4 console.log(`${project.name} (${project.slug})`);
5}
6
7// Filter by organization
8const { data: orgProjects } = await r.projects.list({
9 organization_id: 'org_123',
10});

Parameters:

ParameterTypeDescription
organization_idstring?Filter by organization.
limitnumber?Max results (default 20).
offsetnumber?Pagination offset.

Get a project

1const { data: project } = await r.projects.get('proj_123');
2
3console.log(project.name);
4console.log(project.slug);
5console.log(project.repo_url);
6console.log(project.sandbox?.status); // 'running' | 'stopped' | ...
7console.log(project.databases); // [{ id, name, status }]
8console.log(project.storage_buckets); // [{ id, name }]

The detailed response includes sandbox status, provisioned databases, and storage buckets.

Create a project

1const { data: project } = await r.projects.create({
2 organization_id: 'org_123',
3 name: 'My New App',
4});
5
6console.log(project.id); // 'proj_abc...'
7console.log(project.slug); // 'my-new-app' (auto-generated if not provided)

Input fields:

FieldTypeRequiredDescription
organization_idstringYesThe organization to create the project in.
namestringYesProject name.
slugstring?NoURL slug. Auto-generated from name if omitted.
repo_urlstring?NoGitHub repository URL to link.
template_source'default' | 'custom'?NoTemplate type.
custom_template_urlstring?NoURL to a custom project template.

Delete a project

1const result = await r.projects.delete('proj_123');
2console.log(result.data.deleted); // true

Deleting a project is permanent. All associated sandboxes, databases, storage buckets, and deployments will be destroyed.

Sandbox management

Sandboxes are isolated development environments powered by E2B. Each project can have one active sandbox.

Start a sandbox

1const { data: sandbox } = await r.projects.createSandbox('proj_123');
2
3console.log(sandbox.id);
4console.log(sandbox.status); // 'starting' | 'running'
5console.log(sandbox.message); // 'Sandbox started successfully'

Check sandbox status

1const { data: status } = await r.projects.sandbox('proj_123');
2
3console.log(status.status); // 'running' | 'stopped' | 'error'
4console.log(status.e2b_id); // E2B sandbox ID
5console.log(status.error); // Error message if status === 'error'

Stop a sandbox

1await r.projects.stopSandbox('proj_123');

Execute code

Run code inside the project’s sandbox. The sandbox must be running.

1const { data: result } = await r.projects.executeCode('proj_123', {
2 code: `
3 const response = await fetch('https://api.example.com/data');
4 const data = await response.json();
5 console.log(JSON.stringify(data, null, 2));
6 `,
7 language: 'typescript',
8});
9
10console.log(result.output); // stdout output
11console.log(result.exitCode); // 0 on success
12console.log(result.executionTime); // milliseconds

Supported languages:

LanguageValue
TypeScript'typescript' (default)
JavaScript'javascript'
Python'python'

Deployments

Deploy to production

1const { data: deployment } = await r.projects.deploy('proj_123', {
2 branch: 'main',
3 type: 'production',
4});
5
6console.log(deployment.id);
7console.log(deployment.status); // 'queued' | 'building' | 'deploying' | 'live' | 'failed'
8console.log(deployment.deployment_url); // Live URL once deployed

Deploy input fields:

FieldTypeDefaultDescription
type'production' | 'preview''production'Deployment type.
branchstring?Git branch to deploy.
commit_hashstring?Specific commit to deploy.
commit_messagestring?Commit message for the deployment record.
webhook_urlstring?URL to receive deployment status webhooks.

Create a preview deployment

1const { data: preview } = await r.projects.deploy('proj_123', {
2 branch: 'feature/new-ui',
3 type: 'preview',
4});
5
6console.log(preview.deployment_url); // Unique preview URL

List deployments

1const { data: deployments, meta } = await r.projects.deployments('proj_123');
2
3for (const d of deployments) {
4 console.log(`${d.id} — ${d.status} — ${d.deployment_url ?? 'pending'}`);
5}

Get a specific deployment

1const { data: deployment } = await r.projects.deployment('proj_123', 'deploy_456');
2
3console.log(deployment.status);
4console.log(deployment.branch);
5console.log(deployment.commit_hash);
6console.log(deployment.created_by?.name);
7console.log(deployment.started_at);
8console.log(deployment.completed_at);

Get deployment logs

1const { data: logs } = await r.projects.deploymentLogs('proj_123', 'deploy_456');
2
3console.log(logs.logs); // Build and runtime log output
4
5// Limit log lines
6const { data: recentLogs } = await r.projects.deploymentLogs('proj_123', 'deploy_456', {
7 lines: 50,
8});

Complete workflow

Here is a full example: create a project, start a sandbox, execute code, deploy, and check logs.

1import { Recursiv } from '@recursiv/sdk';
2
3const r = new Recursiv();
4
5// 1. Create the project
6const { data: project } = await r.projects.create({
7 organization_id: 'org_123',
8 name: 'Hello World App',
9});
10console.log('Created project:', project.id);
11
12// 2. Start a sandbox
13const { data: sandbox } = await r.projects.createSandbox(project.id);
14console.log('Sandbox status:', sandbox.status);
15
16// 3. Execute code in the sandbox
17const { data: result } = await r.projects.executeCode(project.id, {
18 code: 'console.log("Hello from Recursiv!")',
19 language: 'typescript',
20});
21console.log('Output:', result.output); // "Hello from Recursiv!\n"
22
23// 4. Deploy to production
24const { data: deployment } = await r.projects.deploy(project.id, {
25 type: 'production',
26 commit_message: 'Initial deployment',
27});
28console.log('Deployment:', deployment.id, deployment.status);
29
30// 5. Poll for deployment completion
31let status = deployment.status;
32while (status !== 'live' && status !== 'failed') {
33 await new Promise((resolve) => setTimeout(resolve, 5000));
34 const { data: updated } = await r.projects.deployment(project.id, deployment.id);
35 status = updated.status;
36 console.log('Status:', status);
37}
38
39// 6. Check deployment logs
40const { data: logs } = await r.projects.deploymentLogs(project.id, deployment.id);
41console.log('Logs:', logs.logs);
42
43// 7. Clean up sandbox when done developing
44await r.projects.stopSandbox(project.id);