Pens

Fork a Pen

Copies one of the key owner's Pens. The copy keeps the original's title, description, tags and access unless given; a fork of a Protected Pen needs a password.

post/v2/pens/{id}/fork

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.

Request body

access'Public' | 'Private' | 'Protected' | 'Collaborators'

Public; Private (not listed on the site; anyone with the link can view it); Protected (private and password protected); Collaborators (private and for collaborators only). Anything but Public needs a PRO plan.

descriptionstring
passwordstring
tagsstring[]
titlestring
waitinteger

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

Response

The new Pen, with build.

access'Public' | 'Private' | 'Protected' | 'Collaborators' required

Public; Private (not listed on the site; anyone with the link can view it); Protected (private and password protected); Collaborators (private and for collaborators only). Anything but Public needs a PRO plan.

created_atstring date-time required
descriptionstring required
editor'Classic' | 'V2' required

V2, or Classic for a Pen made in the classic editor, which is read-only through the API.

idstring required

The cpid, or the hashid for a Pen made in the classic editor.

loves_countinteger required
passwordstring nullable required

Write-only, so always null.

popularityinteger required
tagsstring[] required
templateboolean required
titlestring required
updated_atstring date-time required
views_countinteger required

Views as the site shows them, tallied in batches, so it can trail by a few minutes.

Example response

{
  "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"
      }
    ]
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.