# Upload API

Use the Upload API to upload files to Content Hub. Uploads are completed in three steps:

 1. Generate an upload URL that returns metadata about the upload session. Provide the following information:
      - <b>Configuration</b> settings to use for the upload - an entity that hosts a predefined configuration, which specifies supported file extensions, the permitted file size, the default asset lifecycle for asset creation, and so on.

      - <b>Purpose</b> of the newly uploaded file - create a new asset, use the uploaded file as a new master file for an existing asset, or use the file as an alternate file for an existing asset.

 2. Upload the file to the generated upload URL.

 3. Complete the upload by providing the metadata about the session that was generated in step 1.

 For more information and to see examples, refer to the [Upload API documentation](https://doc.sitecore.com/ch/en/developers/cloud-dev/upload-api.html). For details on how to upload large files, see [Upload large files](https://doc.sitecore.com/ch/en/developers/cloud-dev/upload-large-files.html).

{% admonition type="warning" name="Important" %}The Upload API is not intended for the bulk upload of assets. High volumes of parallel uploads can impact performance. Review [Performance best practices](https://doc.sitecore.com/ch/en/users/content-hub/performance.html) to ensure optimal performance of Content Hub.{% /admonition %}
{% admonition type="info" name="Note" %}Security is applied at the upload configuration level. This means that the user upload permissions depend on the upload configuration entities that users have access to.{% /admonition %}
## Authentication
To use the Upload API, you need:
- The URL of your Content Hub server. You can get this from your Content Hub Administrator. Enter this URL in the <b>{{server}}</b> variable by hovering your mouse over the variable in the <b>Try it</b> pane and then clicking <b>Edit</b>.
- An access token and the client ID. Both are sent with every request. You can create a token through the [Content Hub interface](https://doc.sitecore.com/ch/en/users/content-hub/create-an-oauth-client.html) or by [requesting one using the API itself](https://doc.sitecore.com/ch/en/developers/cloud-dev/oauth-tokens.html#grant-flows).


Version: v2.0
License: closed source
Metadata:
  - product: Content Hub

## Servers

```
https://{server}
```

Variables:
- `server`
Default: "your-server"

## Security

### OAuth2

Type: oauth2

## Download OpenAPI description

[Upload API](https://api-docs.sitecore.com/_bundle/ch/upload-api/@v2.0/index.yaml)

## Upload

The Upload endpoint is used to manage file uploads.  

### Generate an upload URL

 - [POST /api/v2.0/upload](https://api-docs.sitecore.com/ch/upload-api/upload/createuploadurl.md): Generates a URL that can be used to upload a file based on the upload configuration provided. For security reasons, the URL is only valid for a limited time. When uploading a file, you must provide the configuration and action to be performed with the upload. When you upload a file, it can:  - Create a new asset.  - Create a new version of an existing asset.  - Be an alternate file for an existing asset. Uploads require an upload configuration that defines supported file extensions, the content repository to which the file is to be uploaded, and so on. Security checks validate that the user has permission to perform uploads. The upload URL is returned in the response location header.

### Upload a file

 - [POST /api/v2.0/upload/process](https://api-docs.sitecore.com/ch/upload-api/upload/processupload.md): Uploads a file in chunks or as a whole. The URL is generated by the upload URL endpoint. When uploading in chunks, the current chunk number starts at 0 and the total number of chunks must be provided as a query string parameter. Multiple chunks can be uploaded in parallel. To notify that the last chunk has been uploaded and no more are expected, a final request needs to be made with only the parameter of the chunk.

### Finalize the upload process for a file

 - [POST /api/v2.0/upload/finalize](https://api-docs.sitecore.com/ch/upload-api/upload/finalizeupload.md): Finalizes the upload of a file after all chunks have been uploaded. Requires the metadata returned during the creation of the upload URL that identifies the current upload session. When finalizing the upload process, the action configured during the creation of the upload URL is performed.

