# PicHaus API

Use the PicHaus API to browse albums, fetch photos, and deliver a private client gallery from your own tools.

Base URL: `https://pic.haus/api/external`

[Web reference](https://pic.haus/en/docs) · [OpenAPI](https://pic.haus/docs/openapi.json) · [API Keys](https://app.pic.haus/developer)

## Authentication and limits

- Use HTTPS and send `Authorization: Bearer $PICHAUS_API_KEY` on every request, including image downloads. Create your key in API Keys, select only the scopes you need, and store it in a server-side secret. A key is shown only once; revoke it if it is exposed. Do not paste live keys into chat, client code, or URLs.
- Keys can access only active, standard albums you own in your personal workspace. Team albums, albums shared with you, and end-to-end encrypted albums are not included. Public visibility is a filter, not a way around the ownership check.
- All API timestamps are Unix seconds (UTC). Paginated responses include `page`, `limit`, `total`, and `hasMore`; advance `page` until `hasMore` is false. Results can shift between pages if albums or photos change.
- Each account can make 120 read and 30 write requests per minute across all its keys. Requests may also be limited by IP. On `429`, wait for the number of seconds in `Retry-After`.
- Photo responses include `signedUrl` and `signedThumbnailUrl`: presigned storage URLs that fetch the image without your API key until `signedUrlExpiresAt` (about 5 minutes). Do not send your key to them, and request the photo again for fresh URLs. They are `null` when the storage does not support direct delivery; use `url` and `thumbnailUrl` with your key instead.
- Album and view-link creation require an `Idempotency-Key` (1–128 letters, digits, or `._:-`). Use a fresh key for each action. To retry, send the same key and payload within 24 hours. Reusing a key with different input returns `409`; a deleted, expired, revoked, or inaccessible resource is not recreated.

- `albums:read`: List albums and read album details.
- `photos:read`: List and sample photos, check processing, and fetch image bytes.
- `albums:write`: Create private albums and edit their basic details.
- `photos:upload`: Upload photos to an album.
- `share-links:read`: List an album’s active view links, including links made in the app.
- `share-links:write`: Create and revoke expiring view links.

## Quickstart

Create a key with `albums:read` and inject it as `PICHAUS_API_KEY`. The examples use placeholder IDs and responses; set `ALBUM_ID`, `PHOTO_ID`, and `LINK_ID` from real responses and generate unique `CREATE_KEY` and `SHARE_KEY` values before making writes.

```sh
export PICHAUS_API=\
'https://pic.haus/api/external'

curl --fail-with-body \
  "$PICHAUS_API/albums?limit=20" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

To deliver an album, create it, upload each image, poll photo status until processing is complete, then create a view link. Confirm the target album and expiry before creating or revoking a guest link. Never paste a key or private URL into logs.

## Endpoint reference

### List albums

`GET /albums` · scope: `albums:read`

Find your albums by title, description, tags, visibility, or event date. Photo counts include photos still processing. The timeline groups the current page by UTC month, using the creation date if no event date is set.

- `page` (1–10000 (default: 1)): One-based page number.
- `limit` (1–100 (default: 20)): Results per page.
- `order` (asc · desc (default: desc)): Sort direction.
- `q` (string): Case-insensitive literal search of title and description.
- `tag` (string): Match one exact, case-sensitive tag.
- `tags` (string): Match any exact, case-sensitive tag in a comma-separated list. Combined with tag when both are sent.
- `visibility` (all · public · private (default: all)): Filter your albums by publication status.
- `fromEventDate` (integer): Earliest event time, inclusive.
- `toEventDate` (integer): Latest event time, inclusive.
- `sortBy` (createdAt · eventDate · title · updatedAt (default: createdAt)): Album field to sort by.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums?limit=20" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — A page of albums**

```json
{
  "success": true,
  "data": [
    {
      "id": "4a376050-1a88-4a7e-bf03-61a03536c198",
      "title": "Studio proofs",
      "description": null,
      "tags": [
        "proofs"
      ],
      "photoCount": 1,
      "eventDate": null,
      "createdAt": 1785679200,
      "updatedAt": 1785679200,
      "isPublic": false
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 1,
    "hasMore": false
  },
  "summary": {
    "filters": {
      "q": null,
      "tag": null,
      "tags": [],
      "visibility": "all",
      "fromEventDate": null,
      "toEventDate": null,
      "sortBy": "createdAt",
      "order": "desc"
    },
    "timeline": {
      "2026-08": 1
    }
  }
}
```

### Get an album

`GET /albums/{id}` · scope: `albums:read`

Read album details and links to its photo collections. Cover image URLs require photos:read, and its signed URLs are null for keys without that scope. coverPhoto is the selected cover photo or, when the album has no cover of its own, its newest ready landscape-first photo, matching the app. previewImageUrl is that photo’s thumbnail, or null when there is none (including albums whose cover is an uploaded image). The collaborator count includes only collaborators who uploaded at least one photo.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — Success**

```json
{
  "success": true,
  "data": {
    "id": "4a376050-1a88-4a7e-bf03-61a03536c198",
    "title": "Studio proofs",
    "description": null,
    "tags": [
      "proofs"
    ],
    "photoCount": 1,
    "eventDate": null,
    "createdAt": 1785679200,
    "updatedAt": 1785679200,
    "isPublic": false,
    "collaboratorCount": 0,
    "coverPhoto": null,
    "previewImageUrl": null,
    "links": {
      "photos": "https://pic.haus/api/external/albums/4a376050-1a88-4a7e-bf03-61a03536c198/photos",
      "randomPhotos": "https://pic.haus/api/external/albums/4a376050-1a88-4a7e-bf03-61a03536c198/random"
    }
  }
}
```

### Create a private album

`POST /albums` · scope: `albums:write`

Create a standard, private album in your personal workspace. Your plan’s album limit applies. Publication and expiry are managed in the app.

Header: `Idempotency-Key` (required).

Request body: application/json.

- `title` (string, required): Album name.
- `description` (string or null): Album description. Set to null to clear.
- `tags` (array): Replace the tags. Send an empty array to clear.
- `eventDate` (integer or null): Event date in Unix seconds. Set to null to clear.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -X POST \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $CREATE_KEY" \
  --data '{"title":"Studio proofs","tags":["proofs"]}'
```

**201 — Album created or replayed**

```json
{
  "success": true,
  "data": {
    "id": "4a376050-1a88-4a7e-bf03-61a03536c198",
    "title": "Studio proofs",
    "description": null,
    "tags": [
      "proofs"
    ],
    "photoCount": 0,
    "eventDate": null,
    "createdAt": 1785679200,
    "updatedAt": 1785679200,
    "isPublic": false
  }
}
```

### Update an album

`PATCH /albums/{id}` · scope: `albums:write`

Edit an album’s title, description, tags, or event date. Omitted fields are left unchanged. This does not change publication or sharing permissions.

Request body: application/json.

- `title` (string): Album name.
- `description` (string or null): Album description. Set to null to clear.
- `tags` (array): Replace the tags. Send an empty array to clear.
- `eventDate` (integer or null): Event date in Unix seconds. Set to null to clear.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -X PATCH \
  -H 'Content-Type: application/json' \
  --data '{"title":"Studio proofs — final"}'
```

**200 — Success**

```json
{
  "success": true,
  "data": {
    "id": "4a376050-1a88-4a7e-bf03-61a03536c198",
    "title": "Studio proofs — final",
    "description": null,
    "tags": [
      "proofs"
    ],
    "photoCount": 1,
    "eventDate": null,
    "createdAt": 1785679200,
    "updatedAt": 1785679200,
    "isPublic": false
  }
}
```

### List album photos

`GET /albums/{id}/photos` · scope: `photos:read`

List ready photos in one album. Like the self-hosted API, this endpoint omits the selected cover photo; use Get an album for its URLs.

- `page` (1–10000 (default: 1)): One-based page number.
- `limit` (1–100 (default: 50)): Results per page.
- `order` (asc · desc (default: desc)): Sort direction.
- `orientation` (any · landscape · portrait · square (default: any)): Filter by image dimensions before pagination.
- `fromDateTaken` (integer): Earliest capture time, inclusive. Photos without a capture date do not match.
- `toDateTaken` (integer): Latest capture time, inclusive.
- `sortBy` (createdAt · dateTaken · originalName (default: createdAt)): Photo field to sort by.
- `photographer` (UUID or me): Filter by uploader UUID or use me for the key owner.
- `onlyMe` (true · false (default: false)): Set to true to use the key owner regardless of photographer.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/photos?orientation=landscape" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — A page of ready photos**

```json
{
  "success": true,
  "data": [
    {
      "id": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
      "filename": "upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg",
      "originalName": "studio-01.jpg",
      "width": 2400,
      "height": 1600,
      "blurhash": "L6Pj0^i_.AyE_3t7t7R**0o#DgR4",
      "dateTaken": 1785672000,
      "createdAt": 1785679320,
      "url": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/full",
      "thumbnailUrl": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/thumb",
      "signedUrl": "https://storage.example.com/photos/upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
      "signedThumbnailUrl": "https://storage.example.com/thumbnails/7f79938d-54c3-4a68-bc2a-bf59d741e275.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
      "signedUrlExpiresAt": 1785679620
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 1,
    "hasMore": false
  },
  "meta": {
    "filters": {
      "orientation": "landscape",
      "fromDateTaken": null,
      "toDateTaken": null,
      "sortBy": "createdAt",
      "order": "desc"
    }
  }
}
```

### Sample photos from an album

`GET /albums/{id}/random` · scope: `photos:read`

Sample ready photos from one album without including its selected cover. Repeating a request can return different photos.

- `count` (1–50 (default: 1)): Maximum photos to return. Fewer may match.
- `orientation` (any · landscape · portrait · square (default: any)): Filter by image dimensions.
- `fromDateTaken` (integer): Earliest capture time, inclusive. Photos without a capture date do not match.
- `toDateTaken` (integer): Latest capture time, inclusive.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/random?count=1" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — Random ready photos from the album**

```json
{
  "success": true,
  "data": [
    {
      "id": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
      "filename": "upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg",
      "originalName": "studio-01.jpg",
      "width": 2400,
      "height": 1600,
      "blurhash": "L6Pj0^i_.AyE_3t7t7R**0o#DgR4",
      "dateTaken": 1785672000,
      "createdAt": 1785679320,
      "url": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/full",
      "thumbnailUrl": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/thumb",
      "signedUrl": "https://storage.example.com/photos/upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
      "signedThumbnailUrl": "https://storage.example.com/thumbnails/7f79938d-54c3-4a68-bc2a-bf59d741e275.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
      "signedUrlExpiresAt": 1785679620
    }
  ],
  "meta": {
    "filters": {
      "count": 1,
      "orientation": "any",
      "fromDateTaken": null,
      "toDateTaken": null
    }
  }
}
```

### Sample photos across albums

`GET /photos/random` · scope: `photos:read`

Sample ready photos that meet all supplied album and photo filters. By default, only published albums are eligible. Use visibility=all to include private albums or visibility=private to sample only private albums. The result is empty when no photos match.

- `count` (1–50 (default: 1)): Maximum photos to return. Fewer may match.
- `orientation` (any · landscape · portrait · square (default: any)): Filter by image dimensions.
- `fromDateTaken` (integer): Earliest capture time, inclusive. Photos without a capture date do not match.
- `toDateTaken` (integer): Latest capture time, inclusive.
- `q` (string): Case-insensitive literal search of title and description.
- `tag` (string): Match one exact, case-sensitive tag.
- `tags` (string): Match any exact, case-sensitive tag in a comma-separated list. Combined with tag when both are sent.
- `visibility` (all · public · private (default: public)): Filter your albums by publication status.
- `fromEventDate` (integer): Earliest event time, inclusive.
- `toEventDate` (integer): Latest event time, inclusive.
- `albumId` (UUID): Restrict the sample to one album.
- `albumIds` (string): Sample from up to 50 comma-separated album UUIDs. Only IDs accessible to the key can match.

```sh
curl --fail-with-body \
  "$PICHAUS_API/photos/random?count=1&tags=proofs,portfolio&visibility=private" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — Random ready photos with album references**

```json
{
  "success": true,
  "data": [
    {
      "id": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
      "filename": "upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg",
      "originalName": "studio-01.jpg",
      "width": 2400,
      "height": 1600,
      "blurhash": "L6Pj0^i_.AyE_3t7t7R**0o#DgR4",
      "dateTaken": 1785672000,
      "createdAt": 1785679320,
      "url": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/full",
      "thumbnailUrl": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/thumb",
      "signedUrl": "https://storage.example.com/photos/upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
      "signedThumbnailUrl": "https://storage.example.com/thumbnails/7f79938d-54c3-4a68-bc2a-bf59d741e275.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
      "signedUrlExpiresAt": 1785679620,
      "album": {
        "id": "4a376050-1a88-4a7e-bf03-61a03536c198",
        "title": "Studio proofs"
      }
    }
  ],
  "meta": {
    "filters": {
      "count": 1,
      "orientation": "any",
      "fromDateTaken": null,
      "toDateTaken": null,
      "q": null,
      "tag": null,
      "tags": [
        "proofs",
        "portfolio"
      ],
      "visibility": "private",
      "fromEventDate": null,
      "toEventDate": null,
      "albumId": null,
      "albumIds": []
    }
  }
}
```

### Upload a photo

`POST /albums/{id}/photos` · scope: `photos:upload`

Send one image as multipart form data. The default limit is 10 MiB per file; the deployment and your storage quota can impose other limits. Retrying identical bytes in the same album returns the existing photo ID (200). If the other upload is still in flight, wait for Retry-After on 409.

Request body: multipart/form-data.

- `file` (file, required): A single photo file.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/photos" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -F 'file=@studio-01.jpg'
```

**201 — Photo accepted for processing**

```json
{
  "success": true,
  "data": {
    "photoId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "duplicate": false
  }
}
```

**200 — The album already contains these file bytes**

```json
{
  "success": true,
  "data": {
    "photoId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "duplicate": true
  }
}
```

### Upload a desktop-processed photo

`POST /albums/{id}/photos/processed` · scope: `photos:upload`

Send exactly file, thumbnail, and metadata. The server validates image bytes and derives original size, hash, and dimensions. Supplied EXIF and previews skip server extraction and generation. Identical originals return the existing photo without replacing metadata. Poll photo processing before delivery.

Request body: multipart/form-data.

- `file` (file, required): Original image; normal upload size limit, filename up to 512 characters.
- `thumbnail` (file, required): Orientation-correct WebP, at most 400 × 400 pixels and 512 KiB.
- `metadata` (string, required): JSON string with all fields: version:1, blurhash (valid Base83, maximum 166 characters), cameraModel, lens, focalLength, iso, aperture, shutterSpeed, dateTaken. Unknown EXIF values must be null. Strings are at most 255 characters; ISO is an integer 0–2147483647; dateTaken is UTC Unix seconds 0–253402300799. No extra fields.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/photos/processed" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -F 'file=@photo.jpg' -F 'thumbnail=@thumb.webp' -F 'metadata=<metadata.json'
```

**201 — Success**

```json
{
  "success": true,
  "data": {
    "photoId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "duplicate": false
  }
}
```

**200 — Success**

```json
{
  "success": true,
  "data": {
    "photoId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "duplicate": true
  }
}
```

### Prepare a direct S3 upload

`POST /albums/{id}/direct-uploads` · scope: `photos:upload`

Requires operator-enabled direct uploads and S3 storage. Returns a 15-minute signed PUT URL for a private staging object. PUT the exact original bytes with every returned header; never send the API key to S3. A repeated PUT may return 412; proceed to finalize if the first PUT succeeded. Each initiation creates a new session. Admission limits: 20 sessions and 256 MiB per user, 1 GiB globally, counted until expiry. Quota is checked at finalization.

Request body: application/json.

- `filename` (string, required): Original filename.
- `size` (integer, required): Exact original byte length, within the configured upload limit.
- `sha256` (string, required): SHA-256 of the original, lowercase hexadecimal.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/direct-uploads" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -H 'Content-Type: application/json' --data @upload.json
```

**201 — Success**

```json
{
  "success": true,
  "data": {
    "uploadId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "expiresAt": 1800000000,
    "method": "PUT",
    "url": "https://storage.example/signed-upload",
    "headers": {
      "Content-Type": "application/octet-stream",
      "Content-Length": "123456",
      "If-None-Match": "*",
      "x-amz-checksum-sha256": "<base64 SHA-256>"
    }
  }
}
```

### Finalize a direct S3 upload

`POST /albums/{id}/direct-uploads/{uploadId}/finalize` · scope: `photos:upload`

After PUT completes, send exactly thumbnail and metadata. The server reads and verifies the staged original, then persists a canonical copy with normal quota and recovery checks. This is not a zero-copy path. Retry finalization with the same upload ID after network errors. Successful receipts return the same photo ID for at least 24 hours after expiry; deleted photos or unfinished expired sessions return 410. Use the processed multipart route when direct uploads are unavailable.

Request body: multipart/form-data.

- `thumbnail` (file, required): Orientation-correct WebP, at most 400 × 400 pixels and 512 KiB.
- `metadata` (string, required): JSON string with all fields: version:1, blurhash (valid Base83, maximum 166 characters), cameraModel, lens, focalLength, iso, aperture, shutterSpeed, dateTaken. Unknown EXIF values must be null. Strings are at most 255 characters; ISO is an integer 0–2147483647; dateTaken is UTC Unix seconds 0–253402300799. No extra fields.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/direct-uploads/$UPLOAD_ID/finalize" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -F 'thumbnail=@thumb.webp' -F 'metadata=<metadata.json'
```

**201 — Success**

```json
{
  "success": true,
  "data": {
    "photoId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "duplicate": false
  }
}
```

**200 — Success**

```json
{
  "success": true,
  "data": {
    "photoId": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "duplicate": true
  }
}
```

### Check photo processing

`GET /albums/{id}/photos/{photoId}` · scope: `photos:read`

Use the photo ID from an upload to check its status. Pending and processing photos are not yet ready; if processing fails, check the album in PicHaus. Image URLs are null until processing completes.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/photos/$PHOTO_ID" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — Success**

```json
{
  "success": true,
  "data": {
    "id": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "filename": "upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg",
    "originalName": "studio-01.jpg",
    "width": 2400,
    "height": 1600,
    "blurhash": "L6Pj0^i_.AyE_3t7t7R**0o#DgR4",
    "dateTaken": 1785672000,
    "createdAt": 1785679320,
    "url": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/full",
    "thumbnailUrl": "https://pic.haus/api/external/photos/7f79938d-54c3-4a68-bc2a-bf59d741e275/thumb",
    "signedUrl": "https://storage.example.com/photos/upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
    "signedThumbnailUrl": "https://storage.example.com/thumbnails/7f79938d-54c3-4a68-bc2a-bf59d741e275.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=…",
    "signedUrlExpiresAt": 1785679620,
    "processingStatus": "completed"
  }
}
```

**200 — Example while processing**

```json
{
  "success": true,
  "data": {
    "id": "7f79938d-54c3-4a68-bc2a-bf59d741e275",
    "filename": "upload-7f79938d-54c3-4a68-bc2a-bf59d741e275.jpeg",
    "originalName": "studio-01.jpg",
    "width": 2400,
    "height": 1600,
    "blurhash": "L6Pj0^i_.AyE_3t7t7R**0o#DgR4",
    "dateTaken": null,
    "createdAt": 1785679320,
    "url": null,
    "thumbnailUrl": null,
    "signedUrl": null,
    "signedThumbnailUrl": null,
    "signedUrlExpiresAt": null,
    "processingStatus": "pending"
  }
}
```

### Download an image

`GET /photos/{photoId}/{variant}` · scope: `photos:read`

Fetch the thumbnail or original image with the same Bearer key. Responses are image bytes, not JSON or redirects. A missing thumbnail falls back to the original, so check Content-Type. When a photo response includes signedUrl or signedThumbnailUrl, you can fetch those directly without the key instead.

```sh
curl --fail-with-body \
  "$PICHAUS_API/photos/$PHOTO_ID/thumb" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  --output thumbnail.image
```

**200 — Binary image with its actual Content-Type**

### List view links

`GET /albums/{id}/share-links` · scope: `share-links:read`

List the album’s view links that guests can still open, newest first, including links made in the app. Revoked, disabled, and expired links are not included. App links can have no expiry (expiresAt is null), a password, downloads, or a selection of photos (selectedPhotoCount; null means the whole album). Anyone with a link URL can open it, so treat URLs as secrets.

- `page` (1–10000 (default: 1)): One-based page number.
- `limit` (1–100 (default: 50)): Results per page.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/share-links" \
  -H "Authorization: Bearer $PICHAUS_API_KEY"
```

**200 — A page of usable view links**

```json
{
  "success": true,
  "data": [
    {
      "id": "3f87b235-160a-44fa-8da1-bd5946de65fe",
      "url": "https://pic.haus/v/example-view-link-01",
      "label": "Client proofs",
      "expiresAt": 1786284000,
      "createdAt": 1785679400,
      "hasPassword": false,
      "canDownload": false,
      "selectedPhotoCount": null
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 1,
    "hasMore": false
  }
}
```

### Create a view link

`POST /albums/{id}/share-links` · scope: `share-links:write`

Create a link that anyone holding it can use until it expires or is revoked. This does not publish the album, enable downloads, or send email. Set an expiry within 30 days and no later than the album’s expiry.

Header: `Idempotency-Key` (required).

Request body: application/json.

- `expiresAt` (integer, required): Future Unix timestamp in seconds.
- `label` (string): Optional name for this link.

Set the expiry once. Keep the same value and idempotency key when retrying.

```sh
EXPIRES_AT=$(($(date +%s) + 604800))
```

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/share-links" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -X POST \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $SHARE_KEY" \
  --data "{\"label\":\"Client proofs\",\"expiresAt\":$EXPIRES_AT}"
```

**201 — View link created or replayed**

```json
{
  "success": true,
  "data": {
    "id": "3f87b235-160a-44fa-8da1-bd5946de65fe",
    "url": "https://pic.haus/v/example-view-link-01",
    "label": "Client proofs",
    "expiresAt": 1786284000,
    "createdAt": 1785679400,
    "hasPassword": false,
    "canDownload": false,
    "selectedPhotoCount": null
  }
}
```

### Revoke a view link

`DELETE /albums/{id}/share-links/{linkId}` · scope: `share-links:write`

Use the link ID, not the token in the guest URL. Revocation ends access and invalidates guest sessions for that link. Repeating a successful revocation returns 204.

```sh
curl --fail-with-body \
  "$PICHAUS_API/albums/$ALBUM_ID/share-links/$LINK_ID" \
  -H "Authorization: Bearer $PICHAUS_API_KEY" \
  -X DELETE
```

**204 — Link revoked; no response body**

## Errors

- **400** — Invalid request. Check the parameters, body, and required headers.
- **401** — Missing, invalid, expired, or revoked API key.
- **403** — The key is missing a required scope, or the workspace plan does not allow the action.
- **404** — The resource does not exist or is outside the key’s access.
- **409** — The idempotency key was reused with different input, or the same photo is still uploading.
- **410** — The upload session expired or the uploaded photo was deleted.
- **413** — The upload is too large.
- **429** — Rate limit reached. Wait for `Retry-After` before retrying.
- **500** — Unexpected server error. Only retry a write when it is safe to replay.
- **503** — Temporarily unavailable. Honor `Retry-After` when present.

```json
{
  "statusCode": 403,
  "statusMessage": "Missing required scope: photos:read",
  "message": "Missing required scope: photos:read"
}
```

