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

# Projects

> Project management endpoints for creating, updating, and managing projects and their members

# Projects

Projects are the main organizational units in LabTrace. They contain files, have members with different roles, and can be configured with time restrictions and access controls.

## Project Management

### Create Project

<Card title="POST /projects" icon="plus">
  Create a new project
</Card>

### Request Body

```json theme={null}
{
  "name": "Research Project 2024",
  "leader": "John Doe",
  "area": "Biomedical Research",
  "organisation": "Research Institute",
  "location": "New York",
  "tags": ["research", "data", "analysis"],
  "maxNumberOfMembers": "10",
  "organisationScope": "Public",
  "leaderScope": "Full Access",
  "startDate": "2024-01-01T00:00:00Z",
  "endDate": "2024-12-31T23:59:59Z",
  "members": ["user-uuid-1", "user-uuid-2"]
}
```

### Response

```json theme={null}
{
  "responseMessage": "Project created successfully"
}
```

### Example

```bash theme={null}
curl -X POST https://api.labtrace.io/projects \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Research Project 2024",
    "leader": "John Doe",
    "area": "Biomedical Research",
    "organisation": "Research Institute",
    "location": "New York",
    "tags": ["research", "data"],
    "maxNumberOfMembers": "10",
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-12-31T23:59:59Z",
    "members": []
  }'
```

### Get All Projects

<Card title="GET /projects" icon="list">
  Get all projects accessible to the authenticated user
</Card>

### Response

```json theme={null}
{
  "records": [
    {
      "id": "project-uuid",
      "name": "Research Project 2024",
      "area": "Biomedical Research",
      "organisation": "Research Institute",
      "location": "New York",
      "tags": ["research", "data"],
      "leaderId": "user-uuid",
      "leaderFirstName": "John",
      "leaderLastName": "Doe",
      "maxNumberOfMembers": 10,
      "organisationScope": 1,
      "leaderScope": 1,
      "startDate": "2024-01-01T00:00:00Z",
      "endDate": "2024-12-31T23:59:59Z",
      "members": {
        "records": [
          {
            "id": "user-uuid",
            "name": "John",
            "lastName": "Doe",
            "email": "john.doe@example.com",
            "status": "Active"
          }
        ],
        "start": 0,
        "limit": 50,
        "totalRecords": 1
      }
    }
  ],
  "start": 0,
  "limit": 50,
  "totalRecords": 1
}
```

### Get Project by ID

<Card title="GET /projects/{projectId}" icon="info">
  Get detailed information about a specific project
</Card>

### Parameters

* `projectId` (path): Project ID

### Response

```json theme={null}
{
  "id": "project-uuid",
  "name": "Research Project 2024",
  "area": "Biomedical Research",
  "organisation": "Research Institute",
  "location": "New York",
  "tags": ["research", "data"],
  "leaderId": "user-uuid",
  "leaderFirstName": "John",
  "leaderLastName": "Doe",
  "maxNumberOfMembers": 10,
  "organisationScope": 1,
  "leaderScope": 1,
  "startDate": "2024-01-01T00:00:00Z",
  "endDate": "2024-12-31T23:59:59Z",
  "members": {
    "records": [
      {
        "id": "user-uuid",
        "name": "John",
        "lastName": "Doe",
        "email": "john.doe@example.com",
        "status": "Active"
      }
    ],
    "start": 0,
    "limit": 50,
    "totalRecords": 1
  }
}
```

### Update Project

<Card title="PATCH /projects/{projectId}" icon="edit">
  Update project information
</Card>

### Parameters

* `projectId` (path): Project ID

### Request Body

```json theme={null}
{
  "name": "Updated Research Project",
  "area": "Medical Research",
  "organisation": "New Research Institute",
  "location": "Boston",
  "tags": ["research", "medical", "data"],
  "maxNumberOfMembers": 15,
  "organisationScope": "Private",
  "leaderScope": "Limited Access",
  "startDate": "2024-02-01T00:00:00Z",
  "endDate": "2024-11-30T23:59:59Z"
}
```

### Response

```json theme={null}
{
  "responseMessage": "Project updated successfully"
}
```

## Project Members

### Add Project Member

<Card title="POST /projects/{projectId}/members/{userId}" icon="user-plus">
  Add a user to a project
</Card>

### Parameters

* `projectId` (path): Project ID
* `userId` (path): User ID to add to the project

### Response

```json theme={null}
{
  "responseMessage": "Member has been successfully added."
}
```

### Remove Project Member

<Card title="DELETE /projects/{projectId}/members/{userId}" icon="user-minus">
  Remove a user from a project
</Card>

### Parameters

* `projectId` (path): Project ID
* `userId` (path): User ID to remove from the project

### Response

```json theme={null}
{
  "responseMessage": "Member has been successfully removed."
}
```

### Activate Project Member

<Card title="POST /projects/{projectId}/members/{userId}/activate" icon="user-check">
  Activate a project member (accept invitation)
</Card>

### Parameters

* `projectId` (path): Project ID
* `userId` (path): User ID to activate

### Response

```json theme={null}
{
  "responseMessage": "Member has been successfully activated."
}
```

### Get On-Hold Project Members

<Card title="GET /projects/{projectId}/members/on-hold" icon="clock">
  Get all members who have pending invitations
</Card>

### Parameters

* `projectId` (path): Project ID

### Response

```json theme={null}
{
  "records": [
    {
      "id": "user-uuid",
      "name": "Jane",
      "lastname": "Smith",
      "email": "jane.smith@example.com",
      "status": "On-hold"
    }
  ],
  "start": 0,
  "limit": 50,
  "totalRecords": 1
}
```

## Project Validation

### Check Project Creation Permission

<Card title="GET /users/{userId}/can-create-project" icon="shield-check">
  Check if a user can create a new project
</Card>

### Parameters

* `userId` (path): User ID

### Response

```json theme={null}
{
  "info": {
    "statusCode": 200,
    "responseMessage": "User can create project"
  }
}
```

### Check Member Invitation Permission

<Card title="GET /users/{userId}/can-invite-member" icon="shield-check">
  Check if a user can invite members to projects
</Card>

### Parameters

* `userId` (path): User ID

### Response

```json theme={null}
{
  "info": {
    "statusCode": 200,
    "responseMessage": "User can invite members"
  }
}
```

## Member Status

Projects support the following member statuses:

* **Active**: Member has full access to the project
* **On-hold**: Member has a pending invitation

## Project Scopes

Projects can be configured with different scope levels:

* **Organisation Scope**: Controls visibility within the organization
* **Leader Scope**: Controls project leader permissions

## Error Responses

### 400 Bad Request

```json theme={null}
{
  "error": {
    "statusCode": 400,
    "message": "Invalid request parameters"
  }
}
```

### 401 Unauthorized

```json theme={null}
{
  "error": {
    "statusCode": 401,
    "message": "Authentication required"
  }
}
```

### 403 Forbidden

```json theme={null}
{
  "error": {
    "statusCode": 403,
    "message": "Insufficient permissions"
  }
}
```

### 404 Not Found

```json theme={null}
{
  "error": {
    "statusCode": 404,
    "message": "Project not found"
  }
}
```
