How to change photo license via API

I could not find a way to use iNaturalist’s API to change the license of photos that are part of an observation. I have tried to send a PUT request to https://api.inaturalist.org/v1/observations/123456789 with a request body like this:

{
  "observation": {
    "observation_photos": [
      {
        "id": 987654321,
        "photo": {"license_code": "cc-by"}
      }
    ]
  }
}

(Where 123456789 is the ID of an existing observation, and 987654321 is the ID of an existing photo that is part of the observation)

However, this does not change the photo’s license. It seems to delete the photo instead. How do I use iNaturalist’s API to change the license of an existing photo?

if observation 123456789 is tied to photo 123, and you want to set the photo license to CC BY-NC, then you would PUT /v1/photos/123 with body:

{
  "license_code": "CC-BY-NC"
}

if you want to set it to some other photo license, just replace the license_code value with the appropriate code, or if you want to reserve all rights (no license), then use this body:

{
  "license_code": null
}

it’s undocumented, but it works. i think PUT /v2/photos/{id} is documented, but technically v2 is still in beta.

1 Like