# Knowledge Chunk Resource

When you create a Knowledge source, Twilio AI Assistants processes that Knowledge and breaks it into discrete pieces called **Chunks**. These pieces can help you troubleshoot unexpected behavior with your Assistant.

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

## Chunk Properties

<OperationTable type="properties" data={{"type":"object","refName":"assistants.v1.service.knowledge_chunk","modelName":"assistants_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://assistants.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.assistants.v1
    .knowledge("aia_know")
    .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.assistants.v1.knowledge("aia_know").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.Assistants.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: "aia_know", 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.assistants.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("aia_know").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"
	assistants "github.com/twilio/twilio-go/rest/assistants/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 := &assistants.ListKnowledgeChunksParams{}
	params.SetLimit(20)

	resp, err := client.AssistantsV1.ListKnowledgeChunks("aia_know",
		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->assistants->v1->knowledge("aia_know")->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
         .assistants
         .v1
         .knowledge('aia_know')
         .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:assistants:v1:knowledge:chunks:list \
   --id aia_know
```

```bash
curl -X GET "https://assistants.twilio.com/v1/Knowledge/aia_know/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"
  }
}
```
