models

Commit

For legacy reason, we support both application/json and application/x-ndjson but we recommend using application/x-ndjson to create a commit.

JSON-lines payload:

{
  "key": "header",
  "value": {
    "summary": "string (REQUIRED)",
    "description": "string (OPTIONAL - defaults to empty string)",
    "parentCommit": "string (OPTIONAL - 40-character hex SHA)"
  }
}
{
  "key": "file",
  "value": {
    "path": "string (REQUIRED)",
    "content": "string (OPTIONAL - required if oldPath not set)",
    "encoding": "utf-8 | base64 (OPTIONAL - defaults to utf-8)",
    "oldPath": "string (OPTIONAL - for move/rename operations)"
  }
}
{
  "key": "deletedEntry",
  "value": {
    "path": "string (REQUIRED)"
  }
}
{
  "key": "lfsFile",
  "value": {
    "path": "string (REQUIRED - max 1000 chars)",
    "oid": "string (OPTIONAL - required if oldPath not set, 64 hex chars)",
    "algo": "sha256 (OPTIONAL - only sha256 supported)",
    "size": "number (OPTIONAL - required if oldPath is set)",
    "oldPath": "string (OPTIONAL - for move/rename operations)"
  }
}

JSON payload:

{
  "summary": "string (REQUIRED)",
  "description": "string (OPTIONAL - defaults to empty string)",
  "parentCommit": "string (OPTIONAL - 40-character hex SHA)"
  "files": [
    {
      "path": "string (REQUIRED)",
      "content": "string (OPTIONAL - required if oldPath not set)",
      "encoding": "utf-8 | base64 (OPTIONAL - defaults to utf-8)",
      "oldPath": "string (OPTIONAL - for move/rename operations)"
    }
  ],
  "deletedEntries": [
    {
      "path": "string (REQUIRED)"
    }
  ],
  "lfsFiles": [
    {
      "path": "string (REQUIRED - max 1000 chars)",
      "oid": "string (OPTIONAL - required if oldPath not set, 64 hex chars)",
      "algo": "sha256 (OPTIONAL - only sha256 supported)",
      "size": "number (OPTIONAL - required if oldPath is set)",
      "oldPath": "string (OPTIONAL - for move/rename operations)"
    }
  ]
}
post/api/models/{namespace}/{repo}/commit/{rev}

Path parameters

namespacestring required
repostring required
revstring required

Query parameters

create_prstring

Whether to create a pull request from the commit

hot_reloadstring

For Spaces, whether to try to hot reload the commit (only for single python files updates)

Headers

Content-Type'application/json' | 'application/x-ndjson'

application/x-ndjson if you to commit by json lines

Response

The response of the commit

successboolean required

Whether the commit was successful

pullRequestUrlstring

The URL of the pull request

commitOidstring required

The OID of the commit

commitUrlstring required

The URL of the commit

hookOutputstring required

The output of the git hook

Changes

Changed in 1 of the 82 revisions of this API.3

    • ○

      for the header request parameter Content-Type, the type was generalized from no type to string

      request-parameter-type-generalized

    • ○

      for the query request parameter create_pr, the type was generalized from no type to string

      request-parameter-type-generalized

    • ○

      for the query request parameter hot_reload, the type was generalized from no type to string

      request-parameter-type-generalized