Update trail with file upload
const url = 'https://example.com/api/v1/trail/form/example';const form = new FormData();form.append('name', 'example');form.append('description', 'example');form.append('location', 'example');form.append('date', '2026-04-15');form.append('public', 'true');form.append('completed', 'true');form.append('completed_at', '2026-04-15T12:00:00Z');form.append('difficulty', 'easy');form.append('lat', '1');form.append('lon', '1');form.append('distance', '1');form.append('elevation_gain', '1');form.append('elevation_loss', '1');form.append('duration', '1');form.append('photos', 'example');form.append('photos-', 'example');form.append('photos+', 'example');form.append('thumbnail', '1');form.append('like_count', '0');form.append('category', 'example');form.append('subcategory', 'example');form.append('tags', 'example');form.append('gpx', 'example');
const options = {method: 'POST'};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/trail/form/example \ --header 'Content-Type: multipart/form-data' \ --form name=example \ --form description=example \ --form location=example \ --form date=2026-04-15 \ --form public=true \ --form completed=true \ --form completed_at=2026-04-15T12:00:00Z \ --form difficulty=easy \ --form lat=1 \ --form lon=1 \ --form distance=1 \ --form elevation_gain=1 \ --form elevation_loss=1 \ --form duration=1 \ --form photos=example \ --form photos-=example \ --form 'photos+=example' \ --form thumbnail=1 \ --form like_count=0 \ --form category=example \ --form subcategory=example \ --form tags=example \ --form gpx=exampleUpdates a trail with file upload (GPX/photos) and date normalization. The record is addressed by the id path parameter; an id in the body is optional and must match it (400 id_mismatch otherwise). A gpx part replaces the track: the file is converted to GPX (FIT, KML, KMZ and TCX are accepted) and distance, duration, elevation_gain, elevation_loss, lat and lon are derived from it unless the request sets them explicitly. bounding_box_diagonal and polyline are always recomputed.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Remove photo by name
Add photo by name
Responses
Section titled “Responses”Trail updated
object
Trail ID (15 chars)
Trail name
Author user ID
Distance in meters
Elevation gain in meters
Elevation loss in meters
Duration in seconds
Index of thumbnail photo
Category ID (15 chars)
Subcategory ID (15 chars)
GPX file path
Example
{ "difficulty": "easy", "like_count": 0}Bad Request (invalid id, body id differs from the path, or the gpx file cannot be parsed)
Unauthorized
Not Found
Internal Server Error