POST
/
api
/
v1
/
collections
/
{collection_id}
/
photos
Add a photo to a collection
curl --request POST \
  --url https://api.pexafy.com/api/v1/collections/{collection_id}/photos \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "photo_id": "<string>",
  "photo_thumbnail_url": "<string>",
  "photo_source": "<string>",
  "photo_photographer": "<string>"
}
'
import requests

url = "https://api.pexafy.com/api/v1/collections/{collection_id}/photos"

payload = {
"photo_id": "<string>",
"photo_thumbnail_url": "<string>",
"photo_source": "<string>",
"photo_photographer": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
photo_id: '<string>',
photo_thumbnail_url: '<string>',
photo_source: '<string>',
photo_photographer: '<string>'
})
};

fetch('https://api.pexafy.com/api/v1/collections/{collection_id}/photos', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pexafy.com/api/v1/collections/{collection_id}/photos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'photo_id' => '<string>',
'photo_thumbnail_url' => '<string>',
'photo_source' => '<string>',
'photo_photographer' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.pexafy.com/api/v1/collections/{collection_id}/photos"

payload := strings.NewReader("{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.pexafy.com/api/v1/collections/{collection_id}/photos")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.pexafy.com/api/v1/collections/{collection_id}/photos")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"photo_id\": \"<string>\",\n \"photo_thumbnail_url\": \"<string>\",\n \"photo_source\": \"<string>\",\n \"photo_photographer\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "data": {
    "id": 318,
    "photo_id": "019e1a0d-1a4f-7d62-856f-e6775b49785d",
    "photo_thumbnail_url": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=200",
    "photo_source": "Pexels",
    "photo_photographer": "Dip Kheto",
    "added_at": "2026-10-14T09:14:02.118374+00:00"
  },
  "meta": {
    "request_id": "ba9450d4-da83-4122-8311-2f3e19057a38",
    "took_ms": 8.94
  },
  "error": null
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

x-api-key
string
header
required

Pass your Pexafy API key in this header.

Get your API key at pexafy.com/dashboard/api-keys/create.

Path Parameters

collection_id
integer
required

The numeric identifier of the collection to add the photo to.

Body

application/json
photo_id
string
required
Required string length: 1 - 255
photo_thumbnail_url
string | null
Maximum string length: 2048
photo_source
string | null
Maximum string length: 100
photo_photographer
string | null
Maximum string length: 255

Response

Successful Response

success
boolean
data
object
meta
object
error
object | null