Upload API¶
Overview¶
Create a temporary upload request for a file. On success, the API returns an upload ID and a presigned upload URL with the form fields to submit with the file.
Endpoint¶
POST https://api.apidatatools.com/upload-api
Authentication¶
Send your API key in the x-api-key header.
Headers¶
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | string | Yes | Your API key | Authenticates the request. |
Request body¶
Send a JSON object with a filename string.
| Field | Type | Required | Description |
|---|---|---|---|
filename | string | Yes | Filename for the upload. After trimming surrounding whitespace, it must be no longer than 200 characters, contain exactly one period, and have a basename made of letters, numbers, dashes, or underscores. The extension must be one of: json, csv, xml, txt, yml, yaml, html, md, js, css, xls, xlsx, jpg, jpeg, png, gif, webp, sql, or log. |
Example¶
curl --request POST \
--url https://api.apidatatools.com/upload-api \
--header 'x-api-key: YOUR_API_KEY' \
--header 'content-type: application/json' \
--data '{"filename":"report.csv"}'
Success response¶
A successful request returns HTTP 200 with upload_id and upload. The upload object contains a presigned url and fields to use when submitting the file. Its fields include the upload metadata shown below; the presigned response may also contain additional generated fields.
{
"upload_id": "upl_<generated-id>",
"upload": {
"url": "<presigned-upload-url>",
"fields": {
"x-amz-meta-user-id": "<user-id>",
"x-amz-meta-upload-id": "upl_<generated-id>",
"x-amz-meta-original-filename": "report.csv"
}
}
}
The metadata values are supplied in the returned upload form fields. Use the complete fields object returned by the API when submitting the file.
Error handling¶
Errors use an envelope containing status, error, and request_id; details.message contains the error message. details may include additional information.
| HTTP status | Error code | When it occurs |
|---|---|---|
400 | INVALID_INPUT | The request body is not valid JSON. |
400 | INVALID_FILENAME | The filename does not meet the filename requirements. |
400 | INVALID_PLAN | The account’s plan is missing or misconfigured for upload limits. |
400 | QUOTA_EXCEEDED | The account’s storage quota would be exceeded. |
400 | TOO_MANY_UPLOADS | The account has reached its pending-upload limit. |
400 | DDB_ERROR | The upload record could not be created. |
401 | UNAUTHORIZED | Authentication context is missing. |
404 | USER_NOT_FOUND | The authenticated user was not found. |
429 | RATE_LIMITED | The management API rate limit was exceeded. |
500 | PLAN_NOT_FOUND | The account’s plan configuration was not found during authentication. |
500 | INTERNAL_ERROR | An unexpected error occurred. |
Notes¶
- The presigned upload URL expires after five minutes.
- Maximum file size, storage quota, pending-upload limits, and rate limits depend on the account’s plan. See tool limits.