---
title: "Add an Asset"
method: POST
path: "/v2/assets"
tags: ["Assets"]
---

# Add an Asset

`POST /v2/assets`

## Request

- Base URL: `https://api.codepen.io`
- URL: `https://api.codepen.io/v2/assets`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

A multipart `file` part (and `filename`, default the part's own
filename), or JSON `filename` and text `content`. Assets need a PRO
plan; new content counts against the plan's per-file size and total
storage.

## Request body

- AssetRequest
  - `content` string: Text Assets only; send binary files as a multipart `file` part.
  - `filename` string: At most 191 bytes, unique among the owner's Assets, without `/` or `\`.

## Response `201`

The new Asset.

- Asset
  - `created_at` string, date-time, required
  - `filename` string, required
  - `id` string, required
  - `is_binary` boolean, required: Text Assets are those with a text extension: SVG, HTML/HAML/Pug/Slim/Markdown, CSS/Sass/SCSS/Less/Stylus, JS/JSX/TS/TSX/CoffeeScript/JSON/source maps, Vue, GLSL and plain text. Everything else is binary.
  - `updated_at` string, date-time, required
  - `url` string, uri, required

## Other responses

- `400`: `BAD_USER_INPUT`: an invalid parameter, body, path, setting, access level or role. `field` names the argument when known, and `details` carries structured detail (the misses of `PATCH /v2/pens/{id}/files`).
- `401`: `UNAUTHENTICATED`: a missing or invalid key, a deleted owner, or a Team key for a Team that is not PRO.
- `403`: `FORBIDDEN`: a write to a Pen made in the classic editor, or a plan limit (non-Public access, a Private Collection, file size, storage, collaborators). The message names the limit and, when a bigger plan would lift it, where to upgrade.
- `429`: `RATE_LIMITED`: the owner exceeded the plan's requests in an hour, its reads today, or today's allowance of Pen or Collection creates. No `Retry-After` or rate-limit headers are sent; the body carries `retry_after_seconds`, `limit` and `reset_at`.
- `500`: `INTERNAL`: unexpected, and reported; the message is generic.

---

[API](https://skmtc.dev/codepen/apis/codepen-api.md) - [All operations](https://skmtc.dev/codepen/apis/codepen-api/llms.txt) - [OpenAPI document](https://skmtc.dev/codepen/apis/codepen-api/revisions/108fe91e3ef5?raw)
