Objectives

Base Path: `/v1/objectives

Create Objective

Method: POST Endpoint: https://api.tokensource.com/v1/objectives Description: Creates a new objective.

Request Body:

{
  "name": "New Objective",
  "description": "Description of the objective",
  "status": "on_track",
  "metrics": [
    { "key": "metric1", "value": "value1" },
    { "key": "metric2", "value": "value2" }
  ]
}

Response (201 Created):

{
  "message": "Objective created",
  "objective": {
    "id": 1,
    "externalId": "generated-external-id",
    "name": "New Objective",
    "description": "Description of the objective",
    "status": "on_track",
    "userId": 1,
    "createdAt": "2023-10-27T13:00:00Z",
    "updatedAt": "2023-10-27T13:00:00Z",
    "metrics": [
      {
        "id": 1,
        "objectiveId": 1,
        "value": "{\"key\":\"metric1\",\"value\":\"value1\"}",
        "createdAt": "2023-10-27T13:00:00Z"
      }
    ],
    "aiAssistants": []
  }
}

Get All Objectives

Method: GET Endpoint: https://api.tokensource.com/v1/objectives Description: Retrieves all objectives.

Response (200 OK):

[
  {
    "id": 1,
    "externalId": "external-id-1",
    "name": "Objective 1",
    "description": "Description 1",
    "status": "on_track",
    "userId": 1,
    "createdAt": "2023-10-26T10:00:00Z",
    "updatedAt": "2023-10-27T09:00:00Z",
    "metrics": [
      {
        "id": 1,
        "objectiveId": 1,
        "value": "{\"key\":\"metric1\",\"value\":\"value1\"}",
        "createdAt": "2023-10-26T10:00:00Z"
      }
    ],
    "aiAssistants": [
      { "id": 1, "name": "Assistant A" }
    ]
  }
]

Get Objective by ID

Method: GET Endpoint: https://api.tokensource.com/v1/objectives/{id} Description: Retrieves a specific objective by its external ID.

Parameters:

  • id (string, required)

Response (200 OK):

{
  "id": 2,
  "externalId": "external-id-2",
  "name": "Objective 2",
  "description": "Description 2",
  "status": "needs_attention",
  "userId": 1,
  "createdAt": "2023-10-25T14:30:00Z",
  "updatedAt": "2023-10-26T16:00:00Z",
  "metrics": [],
  "aiAssistants": []
}

Response (404 Not Found):

{
  "error": "Objective not found"
}

Update Objective

Method: PUT Endpoint: https://api.tokensource.com/v1/objectives/{id} Description: Updates an existing objective.

Parameters:

  • id (integer, required)

Request Body:

{
  "name": "Updated Objective Name",
  "description": "Updated description",
  "status": "completed",
  "metrics": [
    { "key": "metric1", "value": "updated value1" }
  ],
  "aiAssistantId": 2
}

Response (200 OK):

{
  "message": "Objective updated",
  "objective": {
    "id": 2,
    "externalId": "external-id-2",
    "name": "Updated Objective Name",
    "description": "Updated description",
    "status": "completed",
    "userId": 1,
    "createdAt": "2023-10-25T14:30:00Z",
    "updatedAt": "2023-10-27T14:00:00Z",
    "metrics": [
      {
        "id": 2,
        "objectiveId": 2,
        "value": "{\"key\":\"metric1\",\"value\":\"updated value1\"}",
        "createdAt": "2023-10-27T14:00:00Z"
      }
    ],
    "aiAssistants": [
      { "id": 2, "name": "Assistant B" }
    ]
  }
}

Delete Objective

Method: DELETE Endpoint: https://api.tokensource.com/v1/objectives/{id} Description: Deletes an objective.

Parameters:

  • id (integer, required)

Response (200 OK):

{
  "message": "Objective deleted"
}

`

Last updated