# Components

**Base Path:** `/v1/components`

## Get All Components

**Method:** `GET`\
**Endpoint:** `https://api.tokensource.com/v1/components`\
**Description:** Retrieves all components.

**Response (200 OK):**

```json
{
  "status": 200,
  "data": [
    {
      "id": 1,
      "name": "Component A",
      "parentId": null
    },
    {
      "id": 2,
      "name": "Component B",
      "parentId": 1
    }
  ]
}
```

## Get Component by ID

**Method:** `GET`\
**Endpoint:** `https://api.tokensource.com/v1/components/{id}`\
**Description:** Retrieves a specific component by its ID.

**Parameters:**

* `id` (integer, required)

**Response (200 OK):**

```json
{
  "status": 200,
  "data": {
    "id": 2,
    "name": "Component B",
    "parentId": 1,
    "parent": {
      "id": 1,
      "name": "Component A"
    }
  }
}
```

**Response (404 Not Found):**

```json
{
  "status": 404,
  "message": "Component not found"
}
```

## Create Component

**Method:** `POST`\
**Endpoint:** `https://api.tokensource.com/v1/components`\
**Description:** Creates a new component.

**Request Body:**

```json
{
  "name": "Component C",
  "parentId": 1
}
```

**Response (201 Created):**

```json
{
  "status": 201,
  "data": {
    "id": 3,
    "name": "Component C",
    "parentId": 1
  }
}
```

## Update Component

**Method:** `PUT`\
**Endpoint:** `https://api.tokensource.com/v1/components/{id}`\
**Description:** Updates an existing component.

**Parameters:**

* `id` (integer, required)

**Request Body:**

```json
{
  "name": "Component B Updated",
  "parentId": null
}
```

**Response (200 OK):**

```json
{
  "status": 200,
  "data": {
    "id": 2,
    "name": "Component B Updated",
    "parentId": null
  }
}
```

## Delete Component

**Method:** `DELETE`\
**Endpoint:** `https://api.tokensource.com/v1/components/{id}`\
**Description:** Deletes a component by its ID.

**Parameters:**

* `id` (integer, required)

**Response (200 OK):**

```json
{
  "status": 200,
  "message": "Component deleted successfully"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tokensource.com/components.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
