# Create

`POST /workspaces/:workspace/distributions/:distribution_id/routes`

Create a new route

**Required Scopes:** `DISTRIBUTION_ADD`

## URL Parameters

```typescript
interface URLParameters {
  /** The human-readable ID of the workspace */
  workspace: string; // Example: "my-company"
  /** The ID of the distribution */
  distribution_id: string; // Example: "nZrnl40Y"
}
```

## Query Parameters

```typescript
interface QueryParameters {
  /** Project name to filter distributions */
  project_name?: string; // Example: "my-project"
  /** Environment ID to filter distributions */
  environment_id?: string; // Example: "3a4KbBQl"
}
```

## Body Parameters

```typescript
interface BodyParameters {
  /** The type of the route */
  type: "PROXY" | "REDIRECT" | "CLOAKING" | "PROXY_NO_CACHE";
  /** The targets of the route */
  targets: object;
  /** Subdomain for the route. For a claimable domain, the rightmost label is extracted as the claim. */
  subdomain?: string;
  /** Optional. Domain on which the route is created. */
  domain?: string;
  /** The path of the route */
  path?: string;
}
```

## Response Body

```typescript
interface ResponseBody {
  /** The type of the route */
  type?: "PROXY" | "REDIRECT" | "CLOAKING" | "PROXY_NO_CACHE";
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  /** The ID of the route */
  id?: number;
  /** The subdomain of the route */
  subdomain?: string;
  /** The domain of the route */
  domain?: string;
  /** The path of the route */
  path?: string;
  /** The type of DNS zone for custom domain routing */
  zone_type?: "ROUTING" | "CLAIMABLE" | "USER" | "CLAIMED" | "NS_POINTED" | "CNAME_POINTED";
  /** The targets of the route */
  targets?: object;
}
```

## Request Example

```bash
curl -X POST "https://api.buddy.works/workspaces/:workspace/distributions/:distribution_id/routes" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "PROXY",
  "subdomain": "api",
  "targets": {
    "default": {
      "type": "EXTERNAL",
      "external_url": "https://example.com"
    }
  }
}'
```

## Response Example

**Status:** `201 Created`

```json
{
  "url": "https://api.buddy.works/workspaces/my-workspace/distributions/gNYmaWYw/routes/dybEM2bg?project_name=my-project",
  "html_url": "https://app.buddy.works/my-workspace/my-project/routing/gNYmaWYw/route/dybEM2bg",
  "id": "dybEM2bg",
  "type": "PROXY",
  "subdomain": "sandbox",
  "domain": "buddy.works",
  "path": "",
  "targets": {
    "Default": {
      "type": "SANDBOX",
      "sandbox": {
        "id": "ynjuqe2kov258",
        "endpoint": "www"
      }
    }
  }
}
```

---
Original source: https://buddy.works/docs/api/distributions/routes/create