# Agent Copilot: Knowledge chunk resource (public beta)

> \[!IMPORTANT]
>
> Agent Copilot is currently available as a Public Beta product and the information contained in this document is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Public Beta products are not covered by a SLA.

> \[!WARNING]
>
> Agent Copilot is not a HIPAA Eligible Service or PCI compliant and should not be used in Flex workflows that are subject to HIPAA or PCI. However, we offer mitigation tools such as PII redaction. To learn more, see [AI data use](/docs/flex/admin-guide/setup/copilot#ai-data-use).

When you create a Knowledge source, Agent Copilot processes that Knowledge and breaks it into discrete pieces called **chunks**. These pieces can help you troubleshoot unexpected behavior with Agent Copilot.

This API returns a list of all Knowledge chunks created from uploading Knowledge sources.

## Chunk properties

```json
{"type":"object","refName":"knowledge.v1.service.knowledge_chunk","modelName":"knowledge_v1_service_knowledge_chunk","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","description":"The SID of the [Account](/docs/iam/api/account) that created the Knowledge resource."},"content":{"description":"The chunk content.","type":"string"},"metadata":{"description":"The metadata of the chunk.","type":"object"},"date_created":{"description":"The date and time in GMT when the Chunk was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.","format":"date-time","type":"string"},"date_updated":{"description":"The date and time in GMT when the Chunk was updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.","format":"date-time","type":"string"}}}
```

## List knowledge chunks

`GET https://knowledge.twilio.com/v1/Knowledge/{id}/Chunks`

### Path parameters

```json
[{"in":"path","name":"id","description":"The knowledge ID.","required":true,"schema":{"type":"string"}}]
```

### Query parameters

```json
[{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 1000.","schema":{"type":"integer","minimum":1,"maximum":1000}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

Get chunks for a given Knowledge source

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listKnowledgeChunks() {
  const chunks = await client.knowledge.v1
    .knowledge("id")
    .chunks.list({ limit: 20 });

  chunks.forEach((c) => console.log(c.accountSid));
}

listKnowledgeChunks();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

chunks = client.knowledge.v1.knowledge("id").chunks.list(limit=20)

for record in chunks:
    print(record.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Knowledge.V1.Knowledge;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var chunks = await ChunkResource.ReadAsync(pathId: "id", limit: 20);

        foreach (var record in chunks) {
            Console.WriteLine(record.AccountSid);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.knowledge.Chunk;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Chunk> chunks = Chunk.reader("id").limit(20).read();

        for (Chunk record : chunks) {
            System.out.println(record.getAccountSid());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	knowledge "github.com/twilio/twilio-go/rest/knowledge/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &knowledge.ListKnowledgeChunksParams{}
	params.SetLimit(20)

	resp, err := client.KnowledgeV1.ListKnowledgeChunks("id",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			fmt.Println(resp[record].AccountSid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$chunks = $twilio->knowledge->v1->knowledge("id")->chunks->read(20);

foreach ($chunks as $record) {
    print $record->accountSid;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

chunks = @client
         .knowledge
         .v1
         .knowledge('id')
         .chunks
         .list(limit: 20)

chunks.each do |record|
   puts record.account_sid
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:knowledge:v1:knowledge:chunks:list \
   --id id
```

```bash
curl -X GET "https://knowledge.twilio.com/v1/Knowledge/id/Chunks?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "chunks": [
    {
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "content": "content",
      "metadata": {},
      "date_created": "2009-07-06T20:30:00Z",
      "date_updated": "2009-07-06T20:30:00Z"
    }
  ],
  "meta": {
    "first_page_url": "https://www.example.com",
    "key": "key",
    "next_page_url": "https://www.example.com",
    "page": 42,
    "page_size": 42,
    "previous_page_url": "https://www.example.com",
    "url": "https://www.example.com"
  }
}
```
