time-entries

Start a timer

POST /v1/time-entries/start

Writes require a UUID Idempotency-Key. Retry the same operation with the same key, body and etag. Results are retained for 30 days; reconcile the outcome before retrying later. Legacy timestamp:UUID keys remain accepted.

Start does not stop an existing timer. Switch uses expectedCurrentId/expectedCurrentEtag atomically. Using a preset requires presetEtag.

Parameters

Idempotency-Key

header · Required

Writes require a UUID Idempotency-Key. Retry the same operation with the same key, body and etag. Results are retained for 30 days; reconcile the outcome before retrying later. Legacy timestamp:UUID keys remain accepted.

Type: string

Complete JSON Schema
{
  "type": "string"
}

Request body

Required

application/json

Type: object | object

FieldTypeRequiredDescription and constraints
$ (anyOf 1)objectNo{"additionalProperties":false}
$ (anyOf 1).startTimestringNoStart timestamp in ISO 8601 with a time zone {"format":"date-time"}
$ (anyOf 1).detailstring | nullNoEntry description
$ (anyOf 1).detail (anyOf 1)stringNo{"maxLength":65536}
$ (anyOf 1).detail (anyOf 2)nullNo
$ (anyOf 1).notestring | nullNoNote
$ (anyOf 1).note (anyOf 1)stringNo{"maxLength":65536}
$ (anyOf 1).note (anyOf 2)nullNo
$ (anyOf 1).projectIdstring | nullNoProject ID, or null
$ (anyOf 1).projectId (anyOf 1)stringNo{"minLength":1,"maxLength":512}
$ (anyOf 1).projectId (anyOf 2)nullNo
$ (anyOf 1).tagIdsarray<string>NoTag IDs; comma-separated GET filter, array in bodies {"maxItems":100}
$ (anyOf 1).tagIds[]stringNo{"minLength":1,"maxLength":512}
$ (anyOf 1).expectedCurrentIdstring | nullNoExpected current timer ID, or null if none
$ (anyOf 1).expectedCurrentId (anyOf 1)stringNo{"minLength":1,"maxLength":512}
$ (anyOf 1).expectedCurrentId (anyOf 2)nullNo
$ (anyOf 1).expectedCurrentEtagstringNoExpected current timer ETag {"maxLength":256}
$ (anyOf 2)objectNo{"additionalProperties":false}
$ (anyOf 2).startTimestringNoStart timestamp in ISO 8601 with a time zone {"format":"date-time"}
$ (anyOf 2).detailstring | nullNoEntry description
$ (anyOf 2).detail (anyOf 1)stringNo{"maxLength":65536}
$ (anyOf 2).detail (anyOf 2)nullNo
$ (anyOf 2).notestring | nullNoNote
$ (anyOf 2).note (anyOf 1)stringNo{"maxLength":65536}
$ (anyOf 2).note (anyOf 2)nullNo
$ (anyOf 2).projectIdstring | nullNoProject ID, or null
$ (anyOf 2).projectId (anyOf 1)stringNo{"minLength":1,"maxLength":512}
$ (anyOf 2).projectId (anyOf 2)nullNo
$ (anyOf 2).tagIdsarray<string>NoTag IDs; comma-separated GET filter, array in bodies {"maxItems":100}
$ (anyOf 2).tagIds[]stringNo{"minLength":1,"maxLength":512}
$ (anyOf 2).presetIdstringYesPreset ID {"minLength":1,"maxLength":512}
$ (anyOf 2).presetEtagstringYesCurrent preset ETag {"maxLength":256}
$ (anyOf 2).expectedCurrentIdstring | nullNoExpected current timer ID, or null if none
$ (anyOf 2).expectedCurrentId (anyOf 1)stringNo{"minLength":1,"maxLength":512}
$ (anyOf 2).expectedCurrentId (anyOf 2)nullNo
$ (anyOf 2).expectedCurrentEtagstringNoExpected current timer ETag {"maxLength":256}
Complete JSON Schema
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "startTime": {
          "type": "string",
          "format": "date-time",
          "description": "Start timestamp in ISO 8601 with a time zone"
        },
        "detail": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 65536
            },
            {
              "type": "null"
            }
          ],
          "description": "Entry description"
        },
        "note": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 65536
            },
            {
              "type": "null"
            }
          ],
          "description": "Note"
        },
        "projectId": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            {
              "type": "null"
            }
          ],
          "description": "Project ID, or null"
        },
        "tagIds": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          },
          "maxItems": 100,
          "description": "Tag IDs; comma-separated GET filter, array in bodies"
        },
        "expectedCurrentId": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            {
              "type": "null"
            }
          ],
          "description": "Expected current timer ID, or null if none"
        },
        "expectedCurrentEtag": {
          "type": "string",
          "maxLength": 256,
          "description": "Expected current timer ETag"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "presetId",
        "presetEtag"
      ],
      "properties": {
        "startTime": {
          "type": "string",
          "format": "date-time",
          "description": "Start timestamp in ISO 8601 with a time zone"
        },
        "detail": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 65536
            },
            {
              "type": "null"
            }
          ],
          "description": "Entry description"
        },
        "note": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 65536
            },
            {
              "type": "null"
            }
          ],
          "description": "Note"
        },
        "projectId": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            {
              "type": "null"
            }
          ],
          "description": "Project ID, or null"
        },
        "tagIds": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          },
          "maxItems": 100,
          "description": "Tag IDs; comma-separated GET filter, array in bodies"
        },
        "presetId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512,
          "description": "Preset ID"
        },
        "presetEtag": {
          "type": "string",
          "maxLength": 256,
          "description": "Current preset ETag"
        },
        "expectedCurrentId": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            {
              "type": "null"
            }
          ],
          "description": "Expected current timer ID, or null if none"
        },
        "expectedCurrentEtag": {
          "type": "string",
          "maxLength": 256,
          "description": "Expected current timer ETag"
        }
      },
      "additionalProperties": false
    }
  ]
}

Request example

Replace path and request parameters with actual values. For requests with a body, save it as request.json using the schema above.

curl --fail-with-body --request POST 'https://api.treering.cn/v1/time-entries/start' \
  --header "Authorization: Bearer $TREERING_API_TOKEN" \
  --header 'Idempotency-Key: <Idempotency-Key>' \
  --header 'Content-Type: application/json' \
  --data-binary @request.json

Responses

201

Successful response; status depends on the operation result.

application/json

Type: object

FieldTypeRequiredDescription and constraints
idstringYesResource, job or operation identifier
versionstringYesVersion as a decimal string; do not convert to a floating-point number {"pattern":"^(0|[1-9][0-9]*)$"}
etagstringYesConcurrency tag; preserve quotes when sending If-Match
updatedAtstringYesLast server update timestamp
operationIdstringNoRequest receipt identifier; no status polling is needed
deletedAtstringNoDeletion timestamp
startTimestring | nullNoStart timestamp in ISO 8601 with a time zone
startTime (anyOf 1)stringNo
startTime (anyOf 2)nullNo
stopTimestring | nullNoStop timestamp; null means running
stopTime (anyOf 1)stringNo
stopTime (anyOf 2)nullNo
detailstring | nullNoEntry description
detail (anyOf 1)stringNo
detail (anyOf 2)nullNo
notestring | nullNoNote
note (anyOf 1)stringNo
note (anyOf 2)nullNo
projectIdstring | nullNoProject ID, or null
projectId (anyOf 1)stringNo
projectId (anyOf 2)nullNo
tagIdsarray<string>NoTag IDs; comma-separated GET filter, array in bodies
tagIds[]stringNo
sourcestring | nullNoSource label
source (anyOf 1)stringNo
source (anyOf 2)nullNo
statestringNoEntry, job or operation state; meaning depends on the endpoint
durationSecondsnumber | nullNoDuration in seconds; may be fractional
durationSeconds (anyOf 1)numberNo
durationSeconds (anyOf 2)nullNo
Complete JSON Schema
{
  "type": "object",
  "required": [
    "id",
    "version",
    "etag",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Resource, job or operation identifier"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)$",
      "description": "Version as a decimal string; do not convert to a floating-point number"
    },
    "etag": {
      "type": "string",
      "description": "Concurrency tag; preserve quotes when sending If-Match"
    },
    "updatedAt": {
      "type": "string",
      "description": "Last server update timestamp"
    },
    "operationId": {
      "type": "string",
      "description": "Request receipt identifier; no status polling is needed"
    },
    "deletedAt": {
      "type": "string",
      "description": "Deletion timestamp"
    },
    "startTime": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Start timestamp in ISO 8601 with a time zone"
    },
    "stopTime": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Stop timestamp; null means running"
    },
    "detail": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Entry description"
    },
    "note": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Note"
    },
    "projectId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Project ID, or null"
    },
    "tagIds": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Tag IDs; comma-separated GET filter, array in bodies"
    },
    "source": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Source label"
    },
    "state": {
      "type": "string",
      "description": "Entry, job or operation state; meaning depends on the endpoint"
    },
    "durationSeconds": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Duration in seconds; may be fractional"
    }
  },
  "additionalProperties": false
}

400, 401, 403, 404, 409, 412, 413, 422, 428, 429, 500, 503

Error response; branch on code.

application/json

Type: object

FieldTypeRequiredDescription and constraints
codestringYesMachine-readable error code
messagestringNoError message; use code for program logic
requestIdstringNoRequest trace identifier
operationIdstringNoRequest receipt identifier; no status polling is needed
Complete JSON Schema
{
  "type": "object",
  "required": [
    "code"
  ],
  "properties": {
    "code": {
      "type": "string",
      "description": "Machine-readable error code"
    },
    "message": {
      "type": "string",
      "description": "Error message; use code for program logic"
    },
    "requestId": {
      "type": "string",
      "description": "Request trace identifier"
    },
    "operationId": {
      "type": "string",
      "description": "Request receipt identifier; no status polling is needed"
    }
  },
  "additionalProperties": true
}

On this page