Files
Write files as one version
Applies files changes, in order, as one saved version and builds it. Each change addresses a file by path or id:
| Change | Effect |
|---|---|
| { path, content } | Writes the file at path, creating it if needed. |
| { id, content } | Writes the file with that id, wherever it is. |
| { id, path } | Moves the file to path; it keeps its id. Add content to write there too. |
| { path, delete: true } | Deletes the file, or every file under a directory path. |
| { id, delete: true } | Deletes the file with that id. |
Binary files go up as parts of a multipart form, each one more change applied after those in changes.
put/v2/pens/{id}/files
Request
- Base URLhttps://api.codepen.io
- Auth
- HTTP bearer
- or API key in header X-API-Key
Query parameters
waitinteger
Seconds to wait for the build (default 45, at most 75; 0 answers as soon as the files are saved). A wait in the JSON body takes precedence.
dry_runboolean
Build the proposed files without saving them: the head does not move and the answer's version has saved: false. A dry_run in the JSON body takes precedence.
Request body
Response
The Pen, the newest version the write produced with its files, and that version's build.
Example response
{
"build": {
"files": [
{
"name": "app.js",
"path": "/src/app.js"
}
]
},
"pen": {
"build": {
"files": [
{
"name": "app.js",
"path": "/src/app.js"
}
]
},
"saved_version": {
"build": {
"files": [
{
"name": "app.js",
"path": "/src/app.js"
}
]
},
"files": [
{
"name": "app.js",
"path": "/src/app.js"
}
]
}
},
"version": {
"build": {
"files": [
{
"name": "app.js",
"path": "/src/app.js"
}
]
},
"files": [
{
"name": "app.js",
"path": "/src/app.js"
}
]
}
}Changes
No recorded changes to this operation across all 1 revision of this API.