# Photos

> Documentation index: https://ridewithgps.com/api/v1/doc/llms.txt

Upload a photo to use it in an [experience guide page](https://ridewithgps.com/api/v1/doc/reference/guide_page_blocks.md).

See also: [Publish a multi-day tour](https://ridewithgps.com/api/v1/doc/organizations/publish_tours.md).

OpenAPI specification for these endpoints: https://ridewithgps.com/api/v1/openapi/openapi_photos.yaml

## Uploads a photo

`POST /api/v1/photos.json`

Uploads an image and returns the new photo. Use its `id` wherever a photo id is expected.

**Multipart uploads**: This endpoint accepts only `Content-Type: multipart/form-data`. Send the
image in the `file` field.

The photo has no parent and belongs to the authenticated user. A photo that is not used
anywhere is deleted 24 hours after upload.

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

### Request body (`multipart/form-data`)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | file | yes | Image file |

### Response `201`

| Name | Type | Description |
| --- | --- | --- |
| `photo` | object |  |
| `photo.id` | integer |  |
| `photo.url` | string |  |
| `photo.highlighted` | boolean |  |
| `photo.caption` | string or null |  |
| `photo.lat` | number or null |  |
| `photo.lng` | number or null |  |
| `photo.elevation` | integer or null |  |
| `photo.location` | string or null |  |
| `photo.locality` | string or null |  |
| `photo.administrative_area` | string or null |  |
| `photo.country_code` | string or null |  |
| `photo.created_at` | date-time |  |

### Errors

- `400` Not an image
- `401` Unauthorized

### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  -X POST \
  -F file=@route.gpx \
  https://ridewithgps.com/api/v1/photos.json
```

### Example response

```json
{
  "photo": {
    "id": 123,
    "url": "https://ridewithgps.com/api/v1/photos/123/8275d8de285be31d7b2437bc3ae69756.jpg",
    "highlighted": false,
    "caption": "View from Pittock Mansion",
    "lat": 45.521529,
    "lng": -122.691804,
    "elevation": 290,
    "location": "Pittock Mansion",
    "locality": "Portland",
    "administrative_area": "OR",
    "country_code": "US",
    "created_at": "2000-01-01T12:00:00Z"
  }
}
```
