Files

Write one file

Writes text content as JSON, or a multipart file part, at path as one saved version.

put/v2/pens/{id}/files/{path}

Request

  • Base URL
    https://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

dry_runboolean

Build the proposed files without saving them. The head does not move, and the answer's version has saved: false; it stays readable at GET /v2/versions/{id} for 36 hours.

expected_version_idstring

The saved_version.id the change was built on. The write is refused with 409 if the Pen's head has moved since.

waitinteger

Seconds to wait for the build (default 45, at most 75; 0 answers as soon as the files are saved).

contentstring required

Text only; send a binary file as a multipart file part.

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.