Create a media upload session
curl --request POST \
--url https://api.cope.com/v1/commerce/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blob": {
"byte_size": 52428800,
"checksum": "<string>",
"filename": "<string>"
}
}
'import requests
url = "https://api.cope.com/v1/commerce/uploads"
payload = { "blob": {
"byte_size": 52428800,
"checksum": "<string>",
"filename": "<string>"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({blob: {byte_size: 52428800, checksum: '<string>', filename: '<string>'}})
};
fetch('https://api.cope.com/v1/commerce/uploads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cope.com/v1/commerce/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'blob' => [
'byte_size' => 52428800,
'checksum' => '<string>',
'filename' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cope.com/v1/commerce/uploads"
payload := strings.NewReader("{\n \"blob\": {\n \"byte_size\": 52428800,\n \"checksum\": \"<string>\",\n \"filename\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cope.com/v1/commerce/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"blob\": {\n \"byte_size\": 52428800,\n \"checksum\": \"<string>\",\n \"filename\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/commerce/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"blob\": {\n \"byte_size\": 52428800,\n \"checksum\": \"<string>\",\n \"filename\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"direct_upload": {
"headers": {
"Content-Type": "<string>"
},
"url": "<string>"
},
"upload_token": "<string>"
}
}
Create a media upload session
Step one of three. Returns an upload token and a direct upload URL; send the file bytes to that URL with the returned headers, then attach the token to a product. The URL points at object storage, not at this API. A token is consumed by a successful attach and cannot be reused; a rejected attach leaves it usable.
POST
/
v1
/
commerce
/
uploads
Create a media upload session
curl --request POST \
--url https://api.cope.com/v1/commerce/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blob": {
"byte_size": 52428800,
"checksum": "<string>",
"filename": "<string>"
}
}
'import requests
url = "https://api.cope.com/v1/commerce/uploads"
payload = { "blob": {
"byte_size": 52428800,
"checksum": "<string>",
"filename": "<string>"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({blob: {byte_size: 52428800, checksum: '<string>', filename: '<string>'}})
};
fetch('https://api.cope.com/v1/commerce/uploads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cope.com/v1/commerce/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'blob' => [
'byte_size' => 52428800,
'checksum' => '<string>',
'filename' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cope.com/v1/commerce/uploads"
payload := strings.NewReader("{\n \"blob\": {\n \"byte_size\": 52428800,\n \"checksum\": \"<string>\",\n \"filename\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cope.com/v1/commerce/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"blob\": {\n \"byte_size\": 52428800,\n \"checksum\": \"<string>\",\n \"filename\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/commerce/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"blob\": {\n \"byte_size\": 52428800,\n \"checksum\": \"<string>\",\n \"filename\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"direct_upload": {
"headers": {
"Content-Type": "<string>"
},
"url": "<string>"
},
"upload_token": "<string>"
}
}
Authorizations
Bearer credential for the public API. Vendor integrations should send a live COPE API key (cope_sk_live_*). Clerk bearer tokens are also accepted when paired with X-Cope-Business-Id.
Body
application/json
Show child attributes
Show child attributes
Response
Successful response
Show child attributes
Show child attributes
Was this page helpful?