POST
/
v1
/
files
/
Typescript (SDK)
import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.files.create({
    name: "<value>",
    mimeType: "<value>",
    size: 612128,
    upload: {
      parts: [],
    },
    service: "downloadable",
  });

  console.log(result);
}

run();
{
  "id": "<string>",
  "organization_id": "<string>",
  "name": "<string>",
  "path": "<string>",
  "mime_type": "<string>",
  "size": 123,
  "storage_version": "<string>",
  "checksum_etag": "<string>",
  "checksum_sha256_base64": "<string>",
  "checksum_sha256_hex": "<string>",
  "last_modified_at": "2023-11-07T05:31:56Z",
  "upload": {
    "id": "<string>",
    "path": "<string>",
    "parts": [
      {
        "number": 123,
        "chunk_start": 123,
        "chunk_end": 123,
        "checksum_sha256_base64": "<string>",
        "url": "<string>",
        "expires_at": "2023-11-07T05:31:56Z",
        "headers": {}
      }
    ]
  },
  "version": "<string>",
  "is_uploaded": false,
  "service": "downloadable",
  "size_readable": "<string>"
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Body

application/json

Schema to create a file to be associated with the downloadables benefit.

name
string
required
mime_type
string
required
size
integer
required
upload
object
required
service
string
required
Allowed value: "downloadable"
organization_id
string<uuid4> | null

The organization ID.

Examples:

"1dbfc517-0bbf-4301-9ba8-555ca42b9737"

checksum_sha256_base64
string | null
version
string | null

Response

File created.

id
string<uuid4>
required

The ID of the object.

organization_id
string<uuid4>
required
name
string
required
path
string
required
mime_type
string
required
size
integer
required
storage_version
string | null
required
checksum_etag
string | null
required
checksum_sha256_base64
string | null
required
checksum_sha256_hex
string | null
required
last_modified_at
string<date-time> | null
required
upload
object
required
version
string | null
required
service
enum<string>
required
Available options:
downloadable,
product_media,
organization_avatar
size_readable
string
required
is_uploaded
boolean
default:false