Files
Upload a file
Creates a new file
x-api-key
<token>
API Key for authentication
In: header
namerequired
string
The name of the file
Length
1 <= length <= 50
filerequired
file
The file to upload
Format
binary
Response Body
curl -X POST "https://api.scan-documents.com/v1/files" \
-F name="File Name" \
-F file="string"
const body = new FormData();
body.set(name, "File Name")
body.set(file, "string")
fetch("https://api.scan-documents.com/v1/files", {
body
})
package main
import (
"fmt"
"net/http"
"io/ioutil"
"mime/multipart"
"bytes"
)
func main() {
url := "https://api.scan-documents.com/v1/files"
body := new(bytes.Buffer)
mp := multipart.NewWriter(payload)
mp.WriteField("name", `File Name`)
mp.WriteField("file", `string`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Content-Type", "multipart/form-data")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import requests
url = "https://api.scan-documents.com/v1/files"
body = {
"name": "File Name",
"file": "string"
}
response = requests.request("POST", url, data = body, headers = {
"Content-Type": "multipart/form-data"
})
print(response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;
var body = BodyPublishers.ofByteArray(new byte[] { ... });
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("https://api.scan-documents.com/v1/files"))
.header("Content-Type", "multipart/form-data")
.POST(body)
.build();
try {
HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
System.out.println("Status code: " + response.statusCode());
System.out.println("Response body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;
var body = new MultipartFormDataContent();
var client = new HttpClient();
var response = await client.PostAsync("https://api.scan-documents.com/v1/files", body);
var responseBody = await response.Content.ReadAsStringAsync();
{
"id": "file_euyrvozb9302uwhq",
"name": "Example Image",
"type": "image/png",
"properties": {
"size": 1024,
"width": 800,
"height": 600
},
"task_id": null,
"created_at": "2021-05-01T12:00:00Z"
}
{
"type": "https://scan-documents.com/docs/errors/validation-error",
"title": "Validation Error",
"status": 422,
"errors": {
"{field}": [
"{error}."
]
}
}
{
"type": "https://scan-documents.com/docs/errors/rate-limit-error",
"title": "Rate Limit Exceeded",
"status": 429,
"message": "Rate limit exceeded. Please try again later or contact support."
}
{
"type": "https://scan-documents.com/docs/errors/internal-error",
"title": "An unexpected error occurred. Contact support if the problem persists.",
"status": 500,
"message": "An unexpected error occurred. Contact support if the problem persists."
}