Upload API Reference

This section explains how to upload an image for editing by sending a direct request to our API.

Uploading an image for editing via API

Image upload endpoint allows you to upload an image directly from your computer or server for editing, instead of providing an image URL.

To upload an image, attach an image file as body part of multipart/form-data. The other body part of multipart/form-data should be the same as JSON for a regular image editing request, except there is no input image URL option there. See Image edit contract for more info.

Request

POST /v1-beta1/image/edit/upload HTTP/1.1
Host: api.claid.ai
Authorization: Bearer {YOUR_API_KEY}
Content-Type: multipart/form-data; boundary="boundary"

--boundary
Content-Disposition: form-data; name="file"; filename="the_image"

< ./the_image.jpg

--boundary
Content-Disposition: form-data; name="data"
Content-Type: application/json

{
  "operations": {
    "resizing": {
      "width": 1000
    },
    "background": {
      "remove": false
    }
  }
}

--boundary--

Request headers

Content-Type: multipart/form-data; boundary="boundary"
Authorization: Bearer {YOUR_API_KEY}

In order to send a request, you should set a Content-Type header to let our system know that you are providing a valid form data payload and an Authorization header with a generated API key to identify yourself as a Claid user.

The form data payload should have two blocks of data (body parts), with a delimiter (boundary) separating each block.

The block with an image file should have a Content-Disposition header equal to form-data with two required keys: a name key with a value equal to file and a filename key that will be assigned to an output result image (it is better not to include the extension in a filename, as it can be overwritten by Output options).

Content-Disposition: form-data; name="file"; filename="the_image"

The block with edit operations should have two headers: a Content-Disposition header equal to form-data with a name key with a value equal to data and a Content-Type header to let our system know that you are providing a valid JSON payload.

Content-Disposition: form-data; name="data"
Content-Type: application/json

Response body and headers

The response body and headers is equal to response body and headers of regular image edit request. See the Read a response and Response Headers to learn more.

Last updated