# Agent API

{% file src="<https://3405410158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FceowT5YuHiPO9waGTyaH%2Fuploads%2F3WM4VZUXwJ7TpHQyeIsx%2FAgent%20Public%20API%20Documentation%20updated%20(1).pdf?alt=media&token=354ccc01-1302-40ef-91d6-86c7ad1da230>" %}
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"
 
```
