# Agent API

{% file src="/files/WUbVn9m7gSEmsymlePAa" %}
pdf version of the Agent API documentation
{% endfile %}

## Agent Public API Documentation

#### Note

* Fields marked with `?` are optional.

#### Error Response Format

All error responses are returned in the following format:

```json
{
  "message": "Error message",
  "error": "error code",
  "statusCode": code
}
```

Example:

```json
{
  "message": "Capri token not found",
  "error": "Unauthorized",
  "statusCode": 401
}
```

### Endpoints

#### 1. POST `/v1/agent/create`

**Description:** Create a new agent.

**Request Body:**

```json
{
  "agentName": "string",
  "folder"?: "string",
  "website"?: "string",
  "prompts"?: {
    "name": "string",
    "promptContent": "string",
    "customFallbackPrompt"?: "string"
  }
}
```

**Response:**

```json
{
  "agentName": "new Agent",
  "orgId": "6561047156b3825f13bwc878",
  "userId": "",
  "disabled": false,
  "aiProvider": {
    "companyId": "openai-hosted",
    "modelName": "gpt-4o",
    "accountName": "4O - Capri Hosted",
    "accountId": "capriHosted",
    "isAdvancedSettings": false,
    "advancedSettings": {
      "temperature": 0.3,
      "maxLength": 180,
      "frequencyPenalty": 0,
      "optimize": "accuracy"
    }
  },
  "failsafeAiProvider": {
    "failsafe": false,
    "companyId": "fireworks",
    "modelName": "llama-v3-70b",
    "accountName": "Capri Hosted",
    "accountId": "capriHosted"
  },
  "multipleInbound": false,
  "multipleInboundConfig": {
    "initialWait": 1,
    "maxWait": 10,
    "incrementBy": 30
  },
  "actions": [],
  "savedSessionIds": [],
  "humanTakeover": {
    "takeoverType": "None"
  },
  "contextLength": 1000,
  "textContentKnowledgeSource": null,
  "showNotifications": {
    "connectAgentToTrigger": true
  },
  "_id": "678578dc217db71ewe060b4d6",
  "processingJobs": [],
  "processedFiles": [],
  "triggers": [],
  "variables": [],
  "faqs": [],
  "__v": 0
}
```

#### 2. POST `/v1/agent/{agentId}/update-faq`

**Description:** Add a new FAQ to an agent.

**Params:**

* `agentId` // id of the agent to add the new FAQ.

**Request Body:**

```json
{
  "faqs": [
    {
      "question": "string",
      "answer": "string"
    }
  ]
}
```

**Response:**

```json
{
  "success": true,
  "faqs": [
    {
      "id": "string",
      "question": "string",
      "answer": "string"
    }
  ]
}
```

#### 3. POST `/v1/agent/edit/name`

**Description:** Update an agent’s name.

**Request Body:**

```json
{
  "agentId": "string",
  "agentName": "string"
}
```

**Response:**

```json
{
  "message": "Agent name updated successfully"
}
```

#### 4. POST `/v1/agent/{agentId}/website/scrape`

**Description:** Add websites as a knowledge source to an agent.

**Params:**

* `agentId` // id of the agent to add the website.

**Request Body:**

```json
{
  "urls": ["string"] // URLs of the websites to scrape.
}
```

**Response:**

```json
{
  "success": true,
  "message": "Website processing started",
  "processingJobs": [
    {
      "jobId": "manual-processing-website",
      "accountId": "e33c37-a6a0-4748-8807-07cf194f4e82",
      "fileName": "https://capriai.us",
      "jobType": "website-scrape",
      "maxDepth": 0
    }
  ]
}
```

#### 5. POST `/v1/agent/{agentId}/file-upload`

**Description:** Add a file as a knowledge source to an agent.

**Params:**

* `agentId` // id of the agent to upload the new file.

**Request Body:**

```json
{
  "files": file
}
```

**Response:**

```json
{
  "message": "Files queued for processing",
  "processingJobs": [
    {
      "jobId": "37",
      "accountId": "9772-4e01-a403-8916dc6b1c5a",
      "fileName": "capriai.txt",
      "mimeType": "text/plain",
      "jobType": "file-upload"
    }
  ]
}
```

#### 6. POST `/v1/agent/add/prompt`

**Description:** Add a prompt to an agent.

**Request Body:**

```json
{
  "agentId": "string",
  "prompt": {
    "name": "string",
    "promptContent": "string",
    "customFallbackPrompt"?: "string"
  }
}
```

**Response:**

```json
{
  "message": "New Prompt Pushed Successfully",
  "currentActive": "a17e6aa6-e54f77b-abf7-12080247fe4c",
  "prompt": {
    "promptId": "ff9a69f4-45eb-a119-aed31a75158d",
    "name": "main prompt",
    "promptContent": "You are a bot representing capri AI",
    "isFallbackPrompt": false,
    "customFallbackPrompt": "Say sorry and ask to contact customer support whenever you can't answer"
 
```


---

# 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://help.capriai.us/api-and-developer-tools/using-the-new-public-api/agent-api.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.
