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

# Projects

> API endpoints for managing projects within organizations

## List Projects

<api-endpoint method="GET" path="/organizations/{organization_id}/projects" />

List all projects within an organization.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

### Response

<ResponseField name="projects" type="array">
  Array of project objects with membership details

  <Expandable title="Project Object">
    <ResponseField name="id" type="string">
      Project unique identifier
    </ResponseField>

    <ResponseField name="name" type="string">
      Project name
    </ResponseField>

    <ResponseField name="description" type="string" optional>
      Project description
    </ResponseField>

    <ResponseField name="organization_id" type="string">
      ID of the organization this project belongs to
    </ResponseField>

    <ResponseField name="allowed_domains" type="array">
      Array of domains allowed for this project
    </ResponseField>

    <ResponseField name="created_at" type="string">
      When the project was created (ISO 8601 format)
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      When the project was last updated (ISO 8601 format)
    </ResponseField>

    <ResponseField name="membership" type="object">
      User's membership details in this project

      <Expandable title="Membership Object">
        <ResponseField name="id" type="string">
          Membership unique identifier
        </ResponseField>

        <ResponseField name="user_id" type="string">
          User ID
        </ResponseField>

        <ResponseField name="project_id" type="string">
          Project ID
        </ResponseField>

        <ResponseField name="role" type="string">
          User's role in the project (OWNER, ADMIN, MEMBER, VIEWER)
        </ResponseField>

        <ResponseField name="token" type="string">
          API token for this project membership
        </ResponseField>

        <ResponseField name="created_at" type="string">
          When the membership was created
        </ResponseField>

        <ResponseField name="updated_at" type="string">
          When the membership was last updated
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request GET 'https://api.plaisolutions.com/organizations/org_123/projects' \
  --header 'Authorization: Bearer YOUR_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects`, {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  const projects = await response.json();
  console.log(projects);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.get(url, headers=headers)
  projects = response.json()
  print(projects)
  ```
</CodeGroup>

***

## Create Project

<api-endpoint method="POST" path="/organizations/{organization_id}/projects" />

Create a new project within an organization.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

### Request Body

<ParamField body="name" type="string" required>
  Project name
</ParamField>

<ParamField body="description" type="string" optional>
  Project description
</ParamField>

<ParamField body="allowed_domains" type="array" required>
  Array of domains allowed for this project (e.g., \["example.com", "subdomain.example.com"])
</ParamField>

### Response

Returns the created project object with membership details.

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request POST 'https://api.plaisolutions.com/organizations/org_123/projects' \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "name": "My AI Project",
    "description": "A project for building AI agents",
    "allowed_domains": ["mycompany.com", "app.mycompany.com"]
  }'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: "My AI Project",
      description: "A project for building AI agents",
      allowed_domains: ["mycompany.com", "app.mycompany.com"]
    })
  });

  const project = await response.json();
  console.log(project);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }
  data = {
      "name": "My AI Project",
      "description": "A project for building AI agents",
      "allowed_domains": ["mycompany.com", "app.mycompany.com"]
  }

  response = requests.post(url, headers=headers, json=data)
  project = response.json()
  print(project)
  ```
</CodeGroup>

***

## Get Project

<api-endpoint method="GET" path="/organizations/{organization_id}/projects/{project_id}" />

Get a single project by ID.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

<ParamField path="project_id" type="string" required>
  The unique identifier of the project
</ParamField>

### Response

Returns the project object with membership details.

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request GET 'https://api.plaisolutions.com/organizations/org_123/projects/proj_456' \
  --header 'Authorization: Bearer YOUR_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const projectId = 'proj_456';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects/${projectId}`, {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  const project = await response.json();
  console.log(project);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  project_id = "proj_456"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects/{project_id}"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.get(url, headers=headers)
  project = response.json()
  print(project)
  ```
</CodeGroup>

***

## Update Project

<api-endpoint method="PATCH" path="/organizations/{organization_id}/projects/{project_id}" />

Update an existing project.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

<ParamField path="project_id" type="string" required>
  The unique identifier of the project
</ParamField>

### Request Body

<ParamField body="name" type="string" optional>
  Updated project name
</ParamField>

<ParamField body="description" type="string" optional>
  Updated project description
</ParamField>

<ParamField body="allowed_domains" type="array" optional>
  Updated array of domains allowed for this project
</ParamField>

### Response

Returns the updated project object.

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request PATCH 'https://api.plaisolutions.com/organizations/org_123/projects/proj_456' \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "name": "Updated Project Name",
    "description": "Updated description"
  }'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const projectId = 'proj_456';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects/${projectId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: "Updated Project Name",
      description: "Updated description"
    })
  });

  const project = await response.json();
  console.log(project);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  project_id = "proj_456"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects/{project_id}"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }
  data = {
      "name": "Updated Project Name",
      "description": "Updated description"
  }

  response = requests.patch(url, headers=headers, json=data)
  project = response.json()
  print(project)
  ```
</CodeGroup>

***

## Delete Project

<api-endpoint method="DELETE" path="/organizations/{organization_id}/projects/{project_id}" />

Delete a project. This action cannot be undone and will remove all associated agents, datasources, and other project resources.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

<ParamField path="project_id" type="string" required>
  The unique identifier of the project
</ParamField>

### Response

Returns a 204 status code on successful deletion.

<Warning>
  Deleting a project is irreversible and will permanently remove all associated data including agents, datasources, tools, and usage history.
</Warning>

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request DELETE 'https://api.plaisolutions.com/organizations/org_123/projects/proj_456' \
  --header 'Authorization: Bearer YOUR_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const projectId = 'proj_456';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects/${projectId}`, {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  console.log('Project deleted:', response.status === 204);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  project_id = "proj_456"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects/{project_id}"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.delete(url, headers=headers)
  print(f"Project deleted: {response.status_code == 204}")
  ```
</CodeGroup>

***

## Get Project Statistics

<api-endpoint method="GET" path="/organizations/{organization_id}/projects/{project_id}/stats" />

Get statistics and metrics for a project.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

<ParamField path="project_id" type="string" required>
  The unique identifier of the project
</ParamField>

### Response

<ResponseField name="agents" type="integer">
  Total number of agents in the project
</ResponseField>

<ResponseField name="datasources" type="integer">
  Total number of datasources in the project
</ResponseField>

<ResponseField name="resources" type="integer">
  Total number of resources across all datasources
</ResponseField>

<ResponseField name="tools" type="integer">
  Total number of tools in the project
</ResponseField>

<ResponseField name="requests" type="integer">
  Total number of API requests made in the project
</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request GET 'https://api.plaisolutions.com/organizations/org_123/projects/proj_456/stats' \
  --header 'Authorization: Bearer YOUR_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const projectId = 'proj_456';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects/${projectId}/stats`, {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  const stats = await response.json();
  console.log(stats);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  project_id = "proj_456"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects/{project_id}/stats"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.get(url, headers=headers)
  stats = response.json()
  print(stats)
  ```
</CodeGroup>

<ResponseExample>
  ```json Example Response theme={null}
  {
    "agents": 5,
    "datasources": 3,
    "resources": 127,
    "tools": 8,
    "requests": 1543
  }
  ```
</ResponseExample>

***

## List Project Members

<api-endpoint method="GET" path="/organizations/{organization_id}/projects/{project_id}/members" />

List all members of a project.

### Path Parameters

<ParamField path="organization_id" type="string" required>
  The unique identifier of the organization
</ParamField>

<ParamField path="project_id" type="string" required>
  The unique identifier of the project
</ParamField>

### Response

<ResponseField name="members" type="array">
  Array of member objects

  <Expandable title="Member Object">
    <ResponseField name="id" type="string">
      User unique identifier
    </ResponseField>

    <ResponseField name="email" type="string">
      User's email address
    </ResponseField>

    <ResponseField name="first_name" type="string">
      User's first name
    </ResponseField>

    <ResponseField name="last_name" type="string">
      User's last name
    </ResponseField>

    <ResponseField name="created_at" type="string">
      When the user was created
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      When the user was last updated
    </ResponseField>

    <ResponseField name="membership" type="object">
      Project membership details

      <Expandable title="Project Membership">
        <ResponseField name="id" type="string">
          Membership unique identifier
        </ResponseField>

        <ResponseField name="user_id" type="string">
          User ID
        </ResponseField>

        <ResponseField name="project_id" type="string">
          Project ID
        </ResponseField>

        <ResponseField name="organization_id" type="string">
          Organization ID
        </ResponseField>

        <ResponseField name="role" type="string">
          User's role in the project (OWNER, ADMIN, MEMBER, VIEWER)
        </ResponseField>

        <ResponseField name="token" type="string">
          API token for this project membership
        </ResponseField>

        <ResponseField name="created_at" type="string">
          When the membership was created
        </ResponseField>

        <ResponseField name="updated_at" type="string">
          When the membership was last updated
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request GET 'https://api.plaisolutions.com/organizations/org_123/projects/proj_456/members' \
  --header 'Authorization: Bearer YOUR_TOKEN'
  ```

  ```javascript JavaScript theme={null}
  const organizationId = 'org_123';
  const projectId = 'proj_456';
  const response = await fetch(`https://api.plaisolutions.com/organizations/${organizationId}/projects/${projectId}/members`, {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    }
  });

  const members = await response.json();
  console.log(members);
  ```

  ```python Python theme={null}
  import requests

  organization_id = "org_123"
  project_id = "proj_456"
  url = f"https://api.plaisolutions.com/organizations/{organization_id}/projects/{project_id}/members"
  headers = {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.get(url, headers=headers)
  members = response.json()
  print(members)
  ```
</CodeGroup>

***

## Project Roles

Projects support a hierarchical role-based access control system:

<AccordionGroup>
  <Accordion title="OWNER">
    * Full control over the project
    * Can delete the project
    * Can manage all members and their roles
    * Can modify all project settings
    * Can access all project resources
  </Accordion>

  <Accordion title="ADMIN">
    * Can manage project settings (except deletion)
    * Can invite and remove members
    * Can modify member roles (except OWNER)
    * Can access all project resources
    * Can create and modify agents, tools, and datasources
  </Accordion>

  <Accordion title="MEMBER">
    * Can create and modify agents, tools, and datasources
    * Can access project resources based on permissions
    * Cannot manage project settings or members
    * Can view project statistics
  </Accordion>

  <Accordion title="VIEWER">
    * Read-only access to project resources
    * Can view agents, tools, and datasources
    * Cannot create or modify any resources
    * Can view project statistics
  </Accordion>
</AccordionGroup>

<Note>
  Each project membership includes an API token that can be used for programmatic access to the project's resources. This token inherits the permissions of the user's role in the project.
</Note>
