# Organization Members API

Base URL: `${FORGEJO_URL}/api/v1`

## List Members

```
GET /orgs/{org}/members
```

**Parameters:**
| Name | Type | In | Description |
|------|------|------|-------------|
| page | integer | query | Page number (1-based) |
| limit | integer | query | Page size |

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/members?page=1&limit=20"
```

**Response:** Array of `User` objects.

---

## Check Membership

```
GET /orgs/{org}/members/{username}
```

Returns `204 No Content` if the user is a member, `404` otherwise. Use the response status code to determine membership.

```bash
curl -s -o /dev/null -w "%{http_code}" \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/members/{username}"
```

---

## Remove Member

```
DELETE /orgs/{org}/members/{username}
```

```bash
curl -s -X DELETE \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/members/{username}"
```

Returns `204 No Content` on success.

---

## List Public Members

```
GET /orgs/{org}/public_members
```

**Parameters:**
| Name | Type | In | Description |
|------|------|------|-------------|
| page | integer | query | Page number (1-based) |
| limit | integer | query | Page size |

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/public_members"
```

---

## Check Public Membership

```
GET /orgs/{org}/public_members/{username}
```

Returns `204 No Content` if publicly visible, `404` otherwise.

```bash
curl -s -o /dev/null -w "%{http_code}" \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/public_members/{username}"
```

---

## Publicize Membership

```
PUT /orgs/{org}/public_members/{username}
```

Makes the authenticated user's membership in the organization public.

```bash
curl -s -X PUT \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/public_members/{username}"
```

Returns `204 No Content` on success.

---

## Conceal Membership

```
DELETE /orgs/{org}/public_members/{username}
```

Hides the authenticated user's membership from the public member list.

```bash
curl -s -X DELETE \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/public_members/{username}"
```

Returns `204 No Content` on success.

---

## Get User's Permissions in Organization

```
GET /users/{username}/orgs/{org}/permissions
```

**Response (OrgPermissions):**
| Field | Type | Description |
|-------|------|-------------|
| is_owner | boolean | User is an org owner |
| is_admin | boolean | User is an org admin |
| can_write | boolean | User has write access |
| can_read | boolean | User has read access |
| can_create_repository | boolean | User can create repos in org |

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/users/{username}/orgs/{org}/permissions"
```

**Example Response:**
```json
{
  "is_owner": false,
  "is_admin": true,
  "can_write": true,
  "can_read": true,
  "can_create_repository": true
}
```

---

## Organization Quota

### Get Organization Quota

```
GET /orgs/{org}/quota
```

Returns the overall quota information for the organization.

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/quota"
```

**Response (QuotaInfo):**
| Field | Type | Description |
|-------|------|-------------|
| used | object | Quota usage breakdown |
| groups | array | Quota group assignments |

---

### Get Quota for Artifacts

```
GET /orgs/{org}/quota/artifacts
```

Returns quota usage for CI/CD artifacts.

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/quota/artifacts"
```

**Response:** Array of artifact quota usage objects:
| Field | Type | Description |
|-------|------|-------------|
| name | string | Artifact name |
| size | integer | Size in bytes |

---

### Get Quota for Attachments

```
GET /orgs/{org}/quota/attachments
```

Returns quota usage for issue/release attachments.

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/quota/attachments"
```

**Response:** Array of attachment quota usage objects:
| Field | Type | Description |
|-------|------|-------------|
| name | string | Attachment name |
| size | integer | Size in bytes |

---

### Check Quota

```
GET /orgs/{org}/quota/check
```

Check whether the organization is within its quota limits.

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/quota/check"
```

**Response:** Boolean or status indicating if quota is exceeded.

---

### Get Quota for Packages

```
GET /orgs/{org}/quota/packages
```

Returns quota usage for packages.

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/orgs/{org}/quota/packages"
```

**Response:** Array of package quota usage objects:
| Field | Type | Description |
|-------|------|-------------|
| name | string | Package name |
| size | integer | Size in bytes |
