---
title: "Leave a library"
method: POST
path: "/api/libraries/{library_id}/leave"
tags: ["libraries"]
---

# Leave a library

`POST /api/libraries/{library_id}/leave`

## Request

- Base URL: `https://api.gumnut.ai`
- URL: `https://api.gumnut.ai/api/libraries/{library_id}/leave`
- Auth: HTTP bearer

End the caller's own non-owner membership, even when library content is unavailable. Repeating departure returns the existing inactive state without changing an owner-removal cutoff. An owner cannot leave; retrying unchanged returns 409.

## Path parameters

- `library_id` string, required: Library identifier.

## Response `200`

Successful Response

- MembershipResponse
  - `id` string, required: Stable membership record identifier.
  - `library_id` string, required: Library this membership belongs to.
  - `user` UserSummary, required
    - `id` string, required: User identifier
    - `display_name` string, nullable, required: Public display name, when available
  - `role` 'viewer' | 'collaborator', required: Non-owner library permissions. viewer reads library content. collaborator also edits and organizes content, including trash and restore. Neither administers members or permanently deletes photos.
  - `state` 'active' | 'left' | 'removed', required: A member's library access state. active grants the assigned role. left means the member departed; removed means the owner revoked access. left and removed grant no access.
  - `joined_at` string, date-time, required: Most recent admission instant.
  - `ended_at` string, date-time, nullable, required: Most recent departure or removal instant, or null while active.
  - `last_removed_at` string, date-time, nullable, required: Retained owner-removal cutoff for readmission, or null.
  - `created_at` string, date-time, required: When this record was created.
  - `updated_at` string, date-time, required: When this record last changed.

## Other responses

- `401`: Missing, invalid, or expired credentials.
- `403`: The credentials are valid but not authorized for this operation — for example an API key whose action or library scope excludes it, or a credential type this operation does not accept.
- `404`: Not found
- `409`: `owner_membership_protected`: the owner cannot leave their own library. Retrying unchanged will not clear the conflict. Clerk sign-in could not be associated with the existing account. Resolve the identity conflict before retrying sign-in; repeated requests with unchanged verification and identity state will not resolve it.
- `422`: Validation Error
- `429`: Rate limit exceeded, or too many of your requests are already in progress. Retry after the interval in the `Retry-After` header.
- `503`: Authentication provider temporarily unavailable. Retry sign-in later.

## Changes

- **2026-10-16** `7c2860d9eb88`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gumnut-ai/apis/gumnut-api/changes/api/libraries/:library_id/leave/post.md)

---

[API](https://skmtc.dev/gumnut-ai/apis/gumnut-api.md) · [All operations](https://skmtc.dev/gumnut-ai/apis/gumnut-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gumnut-ai/apis/gumnut-api/revisions/4dcbf19e1db8?raw)
