Layer Uploads
APIs to upload data
With these APIs, you can upload your data to create new layers.
Upload a file or import data from a URL to create a new layer on the map.
The /upload
endpoint can be used for both URL and file uploads:
For URL uploads, simply making a single
POST
request to the upload endpoint is enoughFor file uploads, the response of the initial
POST
request will include a target URL and some pre-signed attributes, which will be used to upload the new file to Amazon S3.
Uploading the file to Amazon S3
Layer files aren't uploaded directly to the Felt API. Instead, they are uploaded by your client directly to an S3 bucket.
You will receive a single set of URL and pre-signed params to upload the file. Only a single file may be uploaded — if you wish to upload several files at once, consider wrapping them in a zip file.
To upload the file using the pre-signed params, you must perform a multipart upload, and include the file contents in the file
field.
# Requires requests library to be installed with: pip install requests
import requests
# Your API token should look like this:
# api_token = "felt_pat_ABCDEFUDQPAGGNBmX40YNhkCRvvLI3f8/BCwD/g8"
api_token = "<YOUR_API_TOKEN>"
map_id = "<YOUR_MAP_ID>"
path_to_file = "<YOUR_FILE_WITH_EXTENSION>" # Example: features.geojson
# Request a pre-signed URL from Felt
layer_response = requests.post(
f"https://felt.com/api/v2/maps/{map_id}/upload",
headers={
"authorization": f"Bearer {api_token}",
"content-type": "application/json",
},
json={"name": "My new layer"},
)
presigned_upload = layer_response.json()
url = presigned_upload["data"]["attributes"]["url"]
presigned_attributes = presigned_upload["data"]["attributes"]["presigned_attributes"]
# A 204 response indicates that the upload was successful
with open(path_to_file, "rb") as file_obj:
output = requests.post(
url,
# Order is important, file should come at the end
files={**presigned_attributes, "file": file_obj},
)
from felt_python import upload_file
upload_file(map_id, file_name="features.geojson", layer_name="My new layer")
The ID of the map to upload the layer to.
A public URL containing geodata to import, in place of uploading a file.
(Image uploads only) The latitude of the image center.
(Image uploads only) The longitude of the image center.
The display name for the new layer.
(Image uploads only) The zoom level of the image.
Upload layer response
UnauthorizedError
UnauthorizedError
NotFoundError
Unprocessable Entity
Unprocessable Entity
InternalServerError
POST /api/v2/maps/{map_id}/upload HTTP/1.1
Host: felt.com
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 311
{
"hints": [
{
"attributes": {
"lat": "text",
"lng": "text"
}
}
],
"import_url": "text",
"lat": 1,
"lng": 1,
"metadata": {
"attribution_text": "text",
"attribution_url": "text",
"description": "text",
"license": "text",
"source_abbreviation": "text",
"source_name": "text",
"source_url": "text",
"updated_at": "2025-03-24"
},
"name": "text",
"zoom": 1
}
{
"layer_group_id": "luCHyMruTQ6ozGk3gPJfEB",
"layer_id": "luCHyMruTQ6ozGk3gPJfEB",
"presigned_attributes": {},
"type": "upload_response",
"url": "text"
}
Create a new layer from an existing data source connection (database, API, or file).
AddSourceLayerAccepted
UnauthorizedError
UnauthorizedError
NotFoundError
Unprocessable Entity
Unprocessable Entity
InternalServerError
POST /api/v2/maps/{map_id}/add_source_layer HTTP/1.1
Host: felt.com
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 56
{
"dataset_id": "luCHyMruTQ6ozGk3gPJfEB",
"from": "dataset"
}
{
"links": {
"layer_group": "https://felt.com/api/v2/maps/V0dnOMOuTd9B9BOsL9C0UjmqC/layer_groups/KFFhKAbvS4anD3wxtwNEpD",
"self": "https://felt.com/api/v2/maps/V0dnOMOuTd9B9BOsL9C0UjmqC"
},
"status": "accepted"
}
Trigger a data refresh for a layer from its original data source to pull in the latest updates.
After uploading a file or URL, you may want to update the resulting layer with some new data. The process is quite similar to the above:
For URL uploads, simply making a single
POST
request to the refresh endpoint is enoughFor file uploads, the response of the initial
POST
request will include a URL and some presigned attributes, which will be used to upload the new file to Amazon S3. See #uploading-the-file-to-amazon-s3 for more details.
from felt_python import (refresh_file_layer, refresh_url_layer)
refresh_file_layer(map_id, layer_id, file_name="features.geojson")
refresh_url_layer(map_id, layer_id)
The ID of the map hosting the layer to refresh
The ID of the layer to refresh
Refresh response
UnauthorizedError
UnauthorizedError
NotFoundError
Unprocessable Entity
Unprocessable Entity
InternalServerError
POST /api/v2/maps/{map_id}/layers/{layer_id}/refresh HTTP/1.1
Host: felt.com
Authorization: Bearer YOUR_API_KEY
Accept: */*
{
"layer_group_id": "luCHyMruTQ6ozGk3gPJfEB",
"layer_id": "luCHyMruTQ6ozGk3gPJfEB",
"presigned_attributes": {},
"type": "upload_response",
"url": "text"
}
Was this helpful?