# Create target with YAML

`POST /workspaces/:workspace/targets/yaml`

Add target from YAML

**Required Scopes:** `TARGET_ADD`

## URL Parameters

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

## Query Parameters

```typescript
interface QueryParameters {
  /** Filter targets by project name */
  project_name?: string; // Example: "my-project"
  /** Filter targets by pipeline ID */
  pipeline_id?: number; // Example: 12345
  /** Filter targets by environment ID */
  environment_id?: string; // Example: "67890"
}
```

## Body Parameters

```typescript
interface BodyParameters {
  /** The Base64-encoded YAML definition of the target */
  yaml?: string;
}
```

## Response Body

```typescript
interface ResponseBody {
  /** Type-specific parameters based on discriminator value */
  __variants?: variants;
}
```

## Request Example

```bash
curl -X POST "https://api.buddy.works/workspaces/:workspace/targets/yaml" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
  "yaml": "LSB0YXJnZXQ6..."
}'
```

## Response Example

**Status:** `201 Created`

```json
{
  "url": "https://api.buddy.works/workspaces/my-workspace/targets/tg-12345",
  "html_url": "https://app.buddy.works/targets/tg-12345",
  "id": "tg-12345",
  "identifier": "production-web-server",
  "name": "Production Web Server",
  "type": "SSH",
  "host": "web.example.com",
  "port": "22",
  "path": "/var/www/html",
  "auth": {
    "method": "SSH_KEY",
    "username": "deploy",
    "asset": "production-ssh-key"
  },
  "tags": [
    "production",
    "web",
    "deploy"
  ],
  "pipelinesAccessLevel": "DENIED",
  "allowedPipelines": [
    {
      "project": "my-project",
      "pipeline": "deploy-pipeline"
    },
    {
      "project": "my-project",
      "pipeline": "hotfix-pipeline"
    }
  ],
  "permissions": {
    "others": "READ_ONLY",
    "users": [
      {
        "id": 42,
        "access_level": "USE_ONLY"
      }
    ],
    "groups": []
  },
  "note": "Notes about this resource",
  "agent_note": "my_custom_field: note for agent"
}
```

---
Original source: https://buddy.works/docs/api/targets/create-with-yaml