> ## 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.

# Create Package

> Create a new package, publishing all draft and modified components

## Request Body

<ParamField body="version" type="string" required>
  Semantic version number (e.g., `1.0.0`, `2.1.0`)
</ParamField>

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="metadata.description" type="string" required>
      Package description
    </ParamField>

    <ParamField body="metadata.tags" type="string[]">
      Package categories
    </ParamField>
  </Expandable>
</ParamField>

### Example Request

```json theme={null}
{
  "version": "1.0.0",
  "metadata": {
    "description": "Initial release with core UI components",
    "tags": ["ui", "core"]
  }
}
```

<Warning>
  Creating a package will automatically publish all draft and modified components, assigning them new version numbers. This action cannot be undone.
</Warning>

## Response

Returns the new package's ID, version, and CDN URL along with validation results showing what changed.

```json theme={null}
{
  "package": {
    "id": "pkg123",
    "version": "1.0.0",
    "cdnUrl": "https://cdn.metabind.ai/org123/proj456/packages/1.0.0/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.json"
  },
  "validation": {
    "componentChanges": {
      "added": ["comp123"],
      "updated": ["comp124", "comp125"],
      "deleted": []
    },
    "statusChanges": {
      "draft": ["comp123"],
      "modified": ["comp124"],
      "published": ["comp125"]
    },
    "versionIncrements": {
      "comp123": { "from": null, "to": 1 },
      "comp124": { "from": 2, "to": 3 }
    }
  }
}
```

## Error Responses

### Version Already Exists

```json theme={null}
{
  "error": {
    "code": "PACKAGE_VERSION_EXISTS",
    "message": "Package version 1.0.0 already exists"
  }
}
```

### No Components

```json theme={null}
{
  "error": {
    "code": "NO_COMPONENTS_TO_PACKAGE",
    "message": "Cannot create package: project contains no components. Create at least one component before creating a package."
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/packages" \
    -H "Authorization: Bearer YOUR_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "version": "1.0.0",
      "metadata": {
        "description": "Initial release"
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/packages',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        version: '1.0.0',
        metadata: {
          description: 'Initial release'
        }
      })
    }
  );

  const { package: pkg, validation } = await response.json();
  console.log(`Created package ${pkg.version} at ${pkg.cdnUrl}`);
  ```
</CodeGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.