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

# Create Scope

> Create a new scope with optional inline memberships

## Request Body

<ParamField body="id" type="string">
  Optional client-provided ID. Format: `scope_{uuidv7}`
</ParamField>

<ParamField body="typeId" type="string" required>
  The scope type ID
</ParamField>

<ParamField body="name" type="string">
  Display name for the scope
</ParamField>

<ParamField body="externalId" type="string">
  External identifier for the scope
</ParamField>

<ParamField body="meta" type="object">
  Optional metadata to associate with the scope
</ParamField>

<ParamField body="parentScopeId" type="string">
  Optional parent scope ID. If provided, automatically creates a scope hierarchy edge.
</ParamField>

<ParamField body="memberships" type="array">
  Optional array of inline memberships to create with the scope. Each membership has:

  * `subjectId` (required): The subject to add to this scope
  * `roleIds` (optional): Array of role IDs to assign to the membership
</ParamField>

## Response

Returns the created scope object.

<Note>
  You can create a scope with its parent relationship and initial memberships in a single request using `parentScopeId` and `memberships`.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.example.com/scopes' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
      "name": "Engineering Team",
      "typeId": "type_team",
      "externalId": "team-eng",
      "parentScopeId": "scope_org",
      "memberships": [
        {"subjectId": "subject_jane", "roleIds": ["role_admin"]},
        {"subjectId": "subject_bob", "roleIds": ["role_member"]}
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "scope_0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b",
    "name": "Engineering Team",
    "typeId": "type_team",
    "externalId": "team-eng"
  }
  ```
</ResponseExample>

## Examples

### Basic Scope

```bash theme={null}
curl -X POST 'https://api.example.com/scopes' \
  -d '{
    "name": "Engineering",
    "typeId": "type_department"
  }'
```

### Scope with Parent

```bash theme={null}
curl -X POST 'https://api.example.com/scopes' \
  -d '{
    "name": "Backend Team",
    "typeId": "type_team",
    "parentScopeId": "scope_engineering"
  }'
```

### Scope with Memberships and Roles

```bash theme={null}
curl -X POST 'https://api.example.com/scopes' \
  -d '{
    "name": "Project Alpha",
    "typeId": "type_project",
    "parentScopeId": "scope_team",
    "memberships": [
      {"subjectId": "subject_jane", "roleIds": ["role_admin", "role_developer"]},
      {"subjectId": "subject_bob", "roleIds": ["role_developer"]},
      {"subjectId": "subject_agent", "roleIds": ["role_viewer"]}
    ]
  }'
```
