Skip to content

Create relation

  • One of the main OpenStreetMap API usabilities

Creates a new relation element. In response you will receive relation ID.

To create new relation you must operate inside an open changeset

Insert the ongoing changeset ID changeset to the request body. After completing various operations on the element, you should close a changset (or it will close automatically). You can also do multiple operations on many elements (create, update, delete) in one ongoing changeset.

In request body the way's IDs ref, member role role and tag k="type" v=" " are also required (check the example).

Request

/api/0.6/relations
Body parameters Inserts options
<member ... role=" "> "outer" / "inner" / "forward" / "backward"
<tag k="type" v=" "> "relation" / "multipolygon"
Example body request for creating relation
<osm>
  <relation changeset="412389">
    <member type="way" ref="4307240014" role="outer"/>
    <member type="way" ref="4307240017" role="outer"/>
    <tag k="type" v="multipolygon"/>
    <tag k="landuse" v="garden"/>
  </relation>
</osm>

Response

relationID_example.xml
4305233945

Error codes

When there are errors parsing the XML (a text message explaining the error is returned). When a changeset ID is missing.

If the request is not a (HTTP) POST request.

If the changeset in question has already been closed either by the user or as a result of the auto-closing feature (example: The changeset 412384 was closed at 2025-04-23 11:51:26 UTC). Also, if the user trying to update the changeset is not the same as the one that created it.

When a relation has elements that do not exist (or do not exist anymore) or are not visible.

When the request has been blocked due to rate limiting.