Upload image

Upload a new PNG, JPEG, or WebP image with optional metadata. Duplicate images, and requests larger than 16MB will be rejected.
POST
/accounts/{accountID}/images
cURL TypeScript Python PHP Ruby Java
1
2
3
4
5
6
7
8
curl -X POST "https://api.moov.io/accounts/{accountID}/images" \
  -H "Authorization: Bearer {token}" \
  --data '{
    "image": "00010101011111000101010110",
    "metadata": {
      "altText": "Blue oat milk carton by Fancy Brand"
    }
  }'\
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Moov } from "@moovio/sdk";
import { openAsBlob } from "node:fs";

const moov = new Moov({
  xMoovVersion: "<value>",
  security: {
    username: "",
    password: "",
  },
});

async function run() {
  const result = await moov.images.upload({
    accountID: "c0971a52-1f1c-4511-876a-f45c4cfd6154",
    imageUploadRequestMultiPart: {
      image: await openAsBlob("example.file"),
    },
  });

  console.log(result);
}

run();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
from moovio_sdk import Moov
from moovio_sdk.models import components


with Moov(
    x_moov_version="<value>",
    security=components.Security(
        username="",
        password="",
    ),
) as moov:

    res = moov.images.upload(account_id="c0971a52-1f1c-4511-876a-f45c4cfd6154", image={
        "file_name": "example.file",
        "content": open("example.file", "rb"),
    })

    # Handle response
    print(res)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
using Moov.Sdk;
using Moov.Sdk.Models.Components;

var sdk = new MoovClient(xMoovVersion: "<value>");

var res = await sdk.Images.UploadAsync(
    accountID: "c0971a52-1f1c-4511-876a-f45c4cfd6154",
    body: new ImageUploadRequestMultiPart() {
        Image = new Image() {
            FileName = "example.file",
            Content = System.IO.File.ReadAllBytes("example.file"),
        },
    }
);

// handle response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
declare(strict_types=1);

require 'vendor/autoload.php';

use Moov\MoovPhp;
use Moov\MoovPhp\Models\Components;

$sdk = MoovPhp\Moov::builder()
    ->setXMoovVersion('<value>')
    ->setSecurity(
        new Components\Security(
            username: '',
            password: '',
        )
    )
    ->build();

$imageUploadRequestMultiPart = new Components\ImageUploadRequestMultiPart(
    image: new Components\Image(
        fileName: 'example.file',
        content: file_get_contents('example.file');,
    ),
);

$response = $sdk->images->upload(
    accountID: 'c0971a52-1f1c-4511-876a-f45c4cfd6154',
    imageUploadRequestMultiPart: $imageUploadRequestMultiPart

);

if ($response->imageMetadata !== null) {
    // handle response
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
require 'moov_ruby'

Models = ::Moov::Models
s = ::Moov::Client.new(
      x_moov_version: '<value>',
    )

res = s.images.upload(account_id: 'c0971a52-1f1c-4511-876a-f45c4cfd6154', image_upload_request_multi_part: Models::Components::ImageUploadRequestMultiPart.new(
  image: Models::Components::Image.new(
    file_name: 'example.file',
    content: File.binread("example.file"),
  ),
))

unless res.image_metadata.nil?
  # handle response
end
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package hello.world;

import java.io.FileInputStream;
import java.lang.Exception;
import org.openapis.openapi.Moov;
import org.openapis.openapi.models.components.*;
import org.openapis.openapi.models.errors.GenericError;
import org.openapis.openapi.models.errors.ImageRequestValidationError;
import org.openapis.openapi.models.operations.UploadImageResponse;
import org.openapis.openapi.utils.Utils;

public class Application {

    public static void main(String[] args) throws GenericError, ImageRequestValidationError, Exception {

        Moov sdk = Moov.builder()
                .xMoovVersion("<value>")
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

        UploadImageResponse res = sdk.images().upload()
                .accountID("c0971a52-1f1c-4511-876a-f45c4cfd6154")
                .imageUploadRequestMultiPart(ImageUploadRequestMultiPart.builder()
                    .image(Image.builder()
                        .fileName("example.file")
                        .content(Utils.readBytesAndClose(new FileInputStream("example.file")))
                        .build())
                    .build())
                .call();

    }
}
201 400 401 403 404 409 422 429 500 504
The resource was successfully created.
application/json
Metadata about an uploaded image.
{
  "imageID": "bbdcb050-2e05-43cb-812a-e1296cd0c01a",
  "publicID": "string",
  "altText": "string",
  "link": "https://api.moov.io/images/qJRAaAwwF5hmfeAFdHjIb",
  "createdOn": "2019-08-24T14:15:22Z",
  "updatedOn": "2019-08-24T14:15:22Z"
}

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The server could not understand the request due to invalid syntax.
application/json
{
  "error": "string"
}

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The request contained missing or expired authentication.

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The user is not authorized to make the request.

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The requested resource was not found.

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The request conflicted with the current state of the target resource.
application/json
{
  "error": "string"
}

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The request was well-formed, but the contents failed validation. Check the request for missing or invalid fields.
application/json
{
  "image": "string",
  "metadata": {
    "altText": "string"
  }
}

x-request-id

string <uuid> required
A unique identifier used to trace requests.
Request was refused due to rate limiting.

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The request failed due to an unexpected error.

x-request-id

string <uuid> required
A unique identifier used to trace requests.
The request failed because a downstream service failed to respond.

x-request-id

string <uuid> required
A unique identifier used to trace requests.

Headers

X-Moov-Version

string

Specify an API version.

API versioning follows the format vYYYY.QQ.BB, where

  • YYYY is the year
  • QQ is the two-digit month for the first month of the quarter (e.g., 01, 04, 07, 10)
  • BB is the build number, starting at .01, for subsequent builds in the same quarter.
    • For example, v2024.01.00 is the initial release of the first quarter of 2024.

The latest version represents the most recent development state. It may include breaking changes and should be treated as a beta release. When no version is specified, the API defaults to v2024.01.00.

Path parameters

accountID

string <uuid> required

Body

multipart/form-data

image

string<binary> required
A PNG, JPEG, or WebP image file to upload.

metadata

object
Optional, json-encoded metadata to associate with the uploaded image.
Request body for creating or updating image metadata.
Show child attributes

altText

string <=125 characters
Alternative text for the image.

Response

application/json
Metadata about an uploaded image.

createdOn

string<date-time> required

imageID

string required
Unique identifier for a image resource.

link

string<uri> required
A public URL to access the image. An optional size={width}x{height} query parameter can be provided to resize the image.

publicID

string required
The ID used to get an image with the public endpoint.
A unique identifier for an image, used in public image links.

updatedOn

string<date-time> required

altText

string <=125 characters
Alternative text for the image.