b2_get_upload_url
    • Dark
      Light

    b2_get_upload_url

    • Dark
      Light

    Article Summary

    Get
    /b2api/v3/b2_get_upload_url

    PLEASE NOTE:

    This API request is now being described as a GET request and not a POST request, as was the case in previous versions of our documentation.

    We made this update because we believe that an API call that retrieves data and does not alter state is more accurately represented as a GET request.

    You may still make a POST request to this endpoint by simply submitting a JSON-formatted request body containing the parameters, with Content-Type set to application/json.


    Returns a URL for uploading files

    When you upload a file to B2, you must call b2_get_upload_url first to get the URL for uploading. Then, you use b2_upload_file on this URL to upload your file.

    An uploadUrl and upload authorizationToken are valid for 24 hours or until the endpoint rejects an upload, see b2_upload_file. You can upload as many files to this URL as you need. To achieve faster upload speeds, request multiple uploadUrls and upload your files to these different endpoints in parallel.

    API Versions

    v1: Application keys (July 26, 2018)

    Incompatible change: After calling b2_authorize_account with an application key that does not have the right permissions, this call will return a 401 Unauthorized.

    v1: Original release (September 22, 2015)

    Header parameters
    Authorization
    stringRequired

    An account authorization token, obtained from b2_authorize_account.
    The token must have the writeFiles capability.

    Query parameters
    bucketId
    stringRequired

    The ID of the bucket that you want to upload to.

    Responses
    200

    The request succeeded.


    The response headers include the Content-Type that was specified when the file was uploaded. They also include the X-Bz-FileName and X-Bz-Content-Sha1 headers, plus X-Bz-Info-* headers for any custom file info that was provided with the upload. The X-Bz-FileName uses percent-encoding, as if it were a URL parameter.

    object
    bucketId
    string

    The identifier for the bucket.

    Example4a48fe8875c6214145260818
    uploadUrl
    string

    The URL that can be used to upload files to this bucket, see b2_upload_file.

    Examplehttps://pod-000-1005-03.backblaze.com/b2api/v3/b2_upload_file?cvt=c001_v0001005_t0027&bucket=4a48fe8875c6214145260818
    authorizationToken
    string

    The authorizationToken that must be used when uploading files to this bucket. This token is valid for 24 hours or until the uploadUrl endpoint rejects an upload, see b2_upload_file

    Example2_20151009170037_f504a0f39a0f4e657337e624_9754dde94359bd7b8f1445c8f4cc1a231a33f714_upld
    400
    statuscodedescription
    400bad_bucket_idThe requested bucket ID does not match an existing bucket.
    400bad_requestThe request had the wrong fields or illegal values. The message returned with the error will describe the problem.
    object
    status
    integer

    The numeric HTTP status code. Always matches the status in the HTTP response.

    Example400
    code
    string

    A single-identifier code that identifies the error.

    Exampleinvalid_bucket_name
    message
    string

    A human-readable message, in English, saying what went wrong.

    Examplebucket name is too long
    401
    statuscodedescription
    401bad_auth_tokenThe auth token used is not valid. Call b2_authorize_account again to either get a new one, or an error message describing the problem.
    401expired_auth_tokenThe auth token used has expired. Call b2_authorize_account again to get a new one.
    401unauthorizedThe auth token used is valid, but does not authorize this call with these parameters. The capabilities of an auth token are determined by the application key used with b2_authorize_account.
    403
    statuscodedescription
    403storage_cap_exceededUsage cap exceeded.
    503
    statuscodedescription
    503service_unavailable<various>

    Was this article helpful?

    What's Next