> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Draft Package

> Preview what would be included in a new package

The draft package endpoint returns a preview of what components and dependencies would be included if you created a new package right now. This is useful for understanding the current state before committing to a new version.

## Path Parameters

<ParamField path="organizationId" type="string" required>
  Organization ID
</ParamField>

<ParamField path="projectId" type="string" required>
  Project ID
</ParamField>

## Query Parameters

<ParamField query="includeDependencies" type="boolean" default="false">
  Set to `true` to include resolved dependencies in the response
</ParamField>

## Response

Returns the draft package in the same format as the resolved package endpoint.

<ResponseField name="id" type="string">
  Always "draft" for the draft package
</ResponseField>

<ResponseField name="version" type="string">
  Always "draft" for the draft package
</ResponseField>

<ResponseField name="components" type="object">
  Map of component names to compiled JavaScript code
</ResponseField>

<ResponseField name="assets" type="object">
  Always empty for draft packages
</ResponseField>

<ResponseField name="dependencies" type="object">
  Map of dependency identifiers to their resolved content (only present if `includeDependencies=true`)
</ResponseField>

### Example Response

```json theme={null}
{
  "id": "draft",
  "version": "draft",
  "components": {
    "Button": "const body = (props) => { return Button(props.label); }",
    "Card": "const body = (props) => { return VStack([...]); }",
    "Header": "const body = (props) => { return HStack([...]); }"
  },
  "assets": {},
  "dependencies": {}
}
```

<Note>
  The draft endpoint is read-only. It does not create or modify any data. It returns the same format as the resolved package endpoint, making it easy to switch between draft and published packages in client code.
</Note>

## Use Cases

### Preview Components Before Publishing

Get the draft package to test components before creating a formal package:

```javascript theme={null}
// Get draft package
const draftResponse = await fetch(
  'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/packages/draft',
  { headers: { 'Authorization': 'Bearer YOUR_JWT' } }
);
const draft = await draftResponse.json();

// List available components
const componentNames = Object.keys(draft.components);
console.log(`Draft package has ${componentNames.length} components`);
componentNames.forEach(name => console.log(`- ${name}`));
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/packages/draft" \
    -H "Authorization: Bearer YOUR_JWT"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/packages/draft',
    {
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      }
    }
  );

  const draft = await response.json();
  console.log(`Draft package contains ${Object.keys(draft.components).length} components`);
  ```
</CodeGroup>
