---
title: "Create a new file in the specified path"
method: POST
path: "/api/contents/{path}"
tags: ["contents"]
---

# Create a new file in the specified path

`POST /api/contents/{path}`

A POST to /api/contents/path creates a New untitled, empty file or directory. A POST to /api/contents/path with body {'copy_from': '/path/to/OtherNotebook.ipynb'} creates a new copy of OtherNotebook in path.

## Path parameters

- `path` string, required

## Request body

- object
  - `copy_from` string
  - `ext` string
  - `type` string

## Response `201`

File created

- Contents — A contents object. The content and format keys may be null if content is not contained. The hash maybe null if hash is not required. If type is 'file', then the mimetype will be null.
  - `name` string, required — Name of file or directory, equivalent to the last part of the path
  - `path` string, required — Full path for file or directory
  - `type` 'directory' | 'file' | 'notebook', required — Type of content
  - `writable` boolean, required — indicates whether the requester has permission to edit the file
  - `created` string, dateTime, required — Creation timestamp
  - `last_modified` string, dateTime, required — Last modified timestamp
  - `size` integer — The size of the file or notebook in bytes. If no size is provided, defaults to null.
  - `mimetype` string, required — The mimetype of a file. If content is not null, and type is 'file', this will contain the mimetype of the file, otherwise this will be null.
  - `content` union — The content, if requested (otherwise null). Will be an array if type is 'directory'
    - string
    - Contents[]
  - `format` string, required — Format of content (one of null, 'text', 'base64', 'json')
  - `hash` string — [optional] The hexdigest hash string of content, if requested (otherwise null). It cannot be null if hash_algorithm is defined.
  - `hash_algorithm` string — [optional] The algorithm used to produce the hash, if requested (otherwise null). It cannot be null if hash is defined.

## Other responses

- `400` — Bad request
- `404` — No item found

## Changes

- **2026-07-17** `b6f1ce06c896` — 1 breaking, 3 info
  - added the new path request parameter `path`
  - added optional request body
  - added the media type `application/json` for the response with the status `201`
  - added the media type `application/json` for the response with the status `400`
- **2025-12-10** `e9ae9d653401` — 3 breaking, 1 warning
  - removed the request body
  - removed the media type `application/json` for the response with the status `201`
  - removed the media type `application/json` for the response with the status `400`
  - deleted the `path` request parameter `path`

[Change history](https://skmtc.dev/google/apis/jupyter-server-api/changes/api/contents/:path/post.md)

---

[API](https://skmtc.dev/google/apis/jupyter-server-api.md) · [All operations](https://skmtc.dev/google/apis/jupyter-server-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/jupyter-server-api/revisions/b6f1ce06c896/schema)
