---
source_url: https://www.pubnub.com/docs/sdks/rest-api/generate-file-upload-url
title: Generate file upload URL
---

# Generate file upload URL

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

Generate a presigned request for file upload.

The response object includes an upload URL, method (such as GET), time to live, and a set of form fields to be included in the request body. You then use these to perform an HTTP operation to perform the file upload to the storage service. Multi-part uploads are supported.

The time to live is generally short, such as one minute. If you make the upload request after the upload URL has expired, the request will fail.

| Path Parameters |
| --- |
| `sub_key`string—**REQUIRED**Your app's subscribe key from Admin Portal. |
| `channel`string—**REQUIRED**The channel ID to perform the operation on. |

| Request Body—**REQUIRED**The request body contains the user-supplied filename |
| --- |
| `name`stringUser-supplied filename |

| Responses |
| --- |
| `200`Successfully generated a file upload requestSchema — OPTIONALstatus integer — OPTIONALStatus codedata object — OPTIONALid string — OPTIONALPubNub-generated unique identifier to add uniqueness to upload file keyname string — OPTIONALUser-defined name after PubNub sanitizationfile_upload_request object — OPTIONALInfo needed to create a file upload requesturl string — OPTIONALFile upload URLmethod string — OPTIONALFile upload URL methodexpiration_date string — OPTIONALExpiration date (ISO 8601 format) for the presigned upload requestform_fields object[] — OPTIONALAn array of form fields to be used in the presigned POST request. You must supply these fields in the order in which you receive them from the server.name string — OPTIONALForm field namevalue string — OPTIONALForm field value | Schema—**OPTIONAL** | `status`integer—**OPTIONAL**Status code | `data`object—**OPTIONAL**id string — OPTIONALPubNub-generated unique identifier to add uniqueness to upload file keyname string — OPTIONALUser-defined name after PubNub sanitization | `id`string—**OPTIONAL**PubNub-generated unique identifier to add uniqueness to upload file key | `name`string—**OPTIONAL**User-defined name after PubNub sanitization | `file_upload_request`object—**OPTIONAL**Info needed to create a file upload requesturl string — OPTIONALFile upload URLmethod string — OPTIONALFile upload URL methodexpiration_date string — OPTIONALExpiration date (ISO 8601 format) for the presigned upload requestform_fields object[] — OPTIONALAn array of form fields to be used in the presigned POST request. You must supply these fields in the order in which you receive them from the server.name string — OPTIONALForm field namevalue string — OPTIONALForm field value | `url`string—**OPTIONAL**File upload URL | `method`string—**OPTIONAL**File upload URL method | `expiration_date`string—**OPTIONAL**Expiration date (ISO 8601 format) for the presigned upload request | `form_fields`object[]—**OPTIONAL**An array of form fields to be used in the presigned POST request. You must supply these fields in the order in which you receive them from the server.name string — OPTIONALForm field namevalue string — OPTIONALForm field value | `name`string—**OPTIONAL**Form field name | `value`string—**OPTIONAL**Form field value |
| Schema—**OPTIONAL** |
| `status`integer—**OPTIONAL**Status code |
| `data`object—**OPTIONAL**id string — OPTIONALPubNub-generated unique identifier to add uniqueness to upload file keyname string — OPTIONALUser-defined name after PubNub sanitization | `id`string—**OPTIONAL**PubNub-generated unique identifier to add uniqueness to upload file key | `name`string—**OPTIONAL**User-defined name after PubNub sanitization |
| `id`string—**OPTIONAL**PubNub-generated unique identifier to add uniqueness to upload file key |
| `name`string—**OPTIONAL**User-defined name after PubNub sanitization |
| `file_upload_request`object—**OPTIONAL**Info needed to create a file upload requesturl string — OPTIONALFile upload URLmethod string — OPTIONALFile upload URL methodexpiration_date string — OPTIONALExpiration date (ISO 8601 format) for the presigned upload requestform_fields object[] — OPTIONALAn array of form fields to be used in the presigned POST request. You must supply these fields in the order in which you receive them from the server.name string — OPTIONALForm field namevalue string — OPTIONALForm field value | `url`string—**OPTIONAL**File upload URL | `method`string—**OPTIONAL**File upload URL method | `expiration_date`string—**OPTIONAL**Expiration date (ISO 8601 format) for the presigned upload request | `form_fields`object[]—**OPTIONAL**An array of form fields to be used in the presigned POST request. You must supply these fields in the order in which you receive them from the server.name string — OPTIONALForm field namevalue string — OPTIONALForm field value | `name`string—**OPTIONAL**Form field name | `value`string—**OPTIONAL**Form field value |
| `url`string—**OPTIONAL**File upload URL |
| `method`string—**OPTIONAL**File upload URL method |
| `expiration_date`string—**OPTIONAL**Expiration date (ISO 8601 format) for the presigned upload request |
| `form_fields`object[]—**OPTIONAL**An array of form fields to be used in the presigned POST request. You must supply these fields in the order in which you receive them from the server.name string — OPTIONALForm field namevalue string — OPTIONALForm field value | `name`string—**OPTIONAL**Form field name | `value`string—**OPTIONAL**Form field value |
| `name`string—**OPTIONAL**Form field name |
| `value`string—**OPTIONAL**Form field value |
| `400`The request body contained invalid dataSchema — OPTIONALstatus integer — OPTIONALStatus codeerror object — OPTIONALsource string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | Schema—**OPTIONAL** | `status`integer—**OPTIONAL**Status code | `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| Schema—**OPTIONAL** |
| `status`integer—**OPTIONAL**Status code |
| `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| `source`string—**OPTIONAL**The PubNub service from which the error originated |
| `message`string—**OPTIONAL**Response message |
| `code`integer—**OPTIONAL**Internal error code |
| `402`The Files service is not enabled for the subkeySchema — OPTIONALstatus integer — OPTIONALStatus codeerror object — OPTIONALsource string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | Schema—**OPTIONAL** | `status`integer—**OPTIONAL**Status code | `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| Schema—**OPTIONAL** |
| `status`integer—**OPTIONAL**Status code |
| `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| `source`string—**OPTIONAL**The PubNub service from which the error originated |
| `message`string—**OPTIONAL**Response message |
| `code`integer—**OPTIONAL**Internal error code |
| `415`The format of the supplied request body isn't supported. The request body must be in JSON format.Schema — OPTIONALstatus integer — OPTIONALStatus codeerror object — OPTIONALsource string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | Schema—**OPTIONAL** | `status`integer—**OPTIONAL**Status code | `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| Schema—**OPTIONAL** |
| `status`integer—**OPTIONAL**Status code |
| `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| `source`string—**OPTIONAL**The PubNub service from which the error originated |
| `message`string—**OPTIONAL**Response message |
| `code`integer—**OPTIONAL**Internal error code |
| `500`Internal Server ErrorSchema — OPTIONALstatus integer — OPTIONALStatus codeerror object — OPTIONALsource string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | Schema—**OPTIONAL** | `status`integer—**OPTIONAL**Status code | `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| Schema—**OPTIONAL** |
| `status`integer—**OPTIONAL**Status code |
| `error`object—**OPTIONAL**source string — OPTIONALThe PubNub service from which the error originatedmessage string — OPTIONALResponse messagecode integer — OPTIONALInternal error code | `source`string—**OPTIONAL**The PubNub service from which the error originated | `message`string—**OPTIONAL**Response message | `code`integer—**OPTIONAL**Internal error code |
| `source`string—**OPTIONAL**The PubNub service from which the error originated |
| `message`string—**OPTIONAL**Response message |
| `code`integer—**OPTIONAL**Internal error code |

sub_key
*
Type:
string
Your app's subscribe key from
[Admin Portal](https://admin.pubnub.com)
.
channel
*
Type:
string
The channel ID to perform the operation on.
The request body contains the user-supplied filename
name
Type:
string
User-supplied filename
Example:
"cat_picture.jpg"
status
Type:
integer
Status code
Example:
200
data
Type:
object
file_upload_request
Type:
object
Info needed to create a file upload request
status
Type:
integer
Status code
Example:
400
error
Type:
object
status
Type:
integer
Status code
Example:
402
error
Type:
object
status
Type:
integer
Status code
Example:
415
error
Type:
object
status
Type:
integer
Status code
Example:
500
error
Type:
object
