---
title: "Create a document"
method: POST
path: "/api/projects/{projectId}/documents"
tags: ["Document"]
---

# Create a document

`POST /api/projects/{projectId}/documents`

Create a new document or directory within a project.

## Path parameters

- `projectId` string, uuid, required

## Request body

- object
  - `name` string, required — Document name
  - `type` 'f' | 'd' | 'e' — Document type (file or directory)
  - `contentType` string — Content MIME type for files
  - `content` unknown
  - `testEvent` string, nullable — Default test event context
  - `parent` string — Parent directory key path
  - `duplicate` boolean — Allow duplicate names
  - `meta` object — Document metadata
  - `source` string — Source document key to copy content from

## Response `200`

Newly created document

- object — Newly created document
  - `id` string, uuid, required — Document unique identifier
  - `key` string, required — Materialized lowercase path based on the name
  - `path` string, required — Materialized path based on the name
  - `name` string, required — Document name
  - `type` 'f' | 'd' | 'e', required — Document type (file, directory, or external file)
  - `meta` object — Document metadata
  - `contentType` string — Content MIME type
  - `size` number — Document size in bytes
  - `parentId` string, uuid, nullable — Parent document ID
  - `projectId` string, uuid, required — Project ID
  - `publishedId` string, uuid, nullable — Currently published version ID
  - `publishedAt` string, nullable — Publication timestamp
  - `publishedBy` object — User who published the document
    - `id` string, uuid, required — User unique identifier
    - `email` string, email — User email address
    - `firstName` string, nullable — User first name
    - `lastName` string, nullable — User last name
  - `published` object — Published version details
    - `id` string, uuid, required — Version unique identifier
    - `name` string, nullable — Version name
    - `parentId` string, uuid, nullable — Parent version ID for sub-versions
    - `status` string — Version status (draft or completed)
    - `content` unknown
    - `documentId` string, uuid — Associated document ID
    - `createdBy` object — User who created the version
      - `id` string, uuid, required — User unique identifier
      - `email` string, email — User email address
      - `firstName` string, nullable — User first name
      - `lastName` string, nullable — User last name
    - `createdAt` string — Version creation timestamp
    - `versions` unknown[] — Sub-versions (recursive structure)
      - unknown
    - `releases` object[] — Associated releases
      - `id` string, uuid, required — Release ID
      - `version` string — Release version string
  - `versions` object[] — Document versions
    - `id` string, uuid, required — Version unique identifier
    - `name` string, nullable — Version name
    - `parentId` string, uuid, nullable — Parent version ID for sub-versions
    - `status` string — Version status (draft or completed)
    - `content` unknown
    - `documentId` string, uuid — Associated document ID
    - `createdBy` object — User who created the version
      - `id` string, uuid, required — User unique identifier
      - `email` string, email — User email address
      - `firstName` string, nullable — User first name
      - `lastName` string, nullable — User last name
    - `createdAt` string — Version creation timestamp
    - `versions` unknown[] — Sub-versions (recursive structure)
      - unknown
    - `releases` object[] — Associated releases
      - `id` string, uuid, required — Release ID
      - `version` string — Release version string
  - `changeRequests` object[] — Pending change requests
    - `id` string, uuid, required — Change request unique identifier
    - `type` string, required — Type of change request
    - `status` string, required — Change request status
    - `createdAt` string — Creation timestamp
  - `view` object, nullable — Document view configuration
    - `description` string, nullable — View description
    - `permissions` object, nullable — View permissions mapping
  - `updatedAt` string — Last update timestamp
  - `deletedAt` string, nullable — Deletion timestamp if soft deleted

---

[API](https://skmtc.dev/gorules/apis/gorules-agent-api.md) · [All operations](https://skmtc.dev/gorules/apis/gorules-agent-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/gorules/gorules-agent-api/revisions/52c0773fcd80/schema)
