# Agent Copilot: Knowledge 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).

The Knowledge API lets you programmatically upload your unstructured data sources for Agent Copilot to use.

## Knowledge properties

```json
{"type":"object","required":["id","name","type","date_created","date_updated"],"properties":{"description":{"description":"The type of knowledge source.","type":"string"},"id":{"type":"string","pattern":"^aia_know_.+$","description":"The description of knowledge."},"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."},"knowledge_source_details":{"description":"The details of the knowledge source based on the type.","type":"object"},"name":{"description":"The name of the knowledge source.","type":"string"},"status":{"description":"The status of processing the knowledge source ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED')","type":"string"},"type":{"description":"The type of knowledge source ('Web', 'Database', 'Text', 'File')","type":"string"},"url":{"type":"string","description":"The url of the knowledge resource."},"embedding_model":{"description":"The embedding model to be used for the knowledge source.","type":"string"},"date_created":{"description":"The date and time in GMT when the Knowledge 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 Knowledge was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.","format":"date-time","type":"string"}}}
```

## Create a new Knowledge source

`POST https://knowledge.twilio.com/v1/Knowledge`

### Request body parameters

```json
{"schema":{"type":"object","required":["name","type"],"refName":"knowledge.v1.service.create_knowledge_request","modelName":"knowledge_v1_service_create_knowledge_request","properties":{"description":{"description":"The description of the knowledge source.","type":"string"},"knowledge_source_details":{"description":"The details of the knowledge source based on the type.","type":"object"},"name":{"description":"The name of the tool.","type":"string"},"policy":{"description":"The policy associated with the knowledge source.","type":"object","required":["policy_details"],"refName":"knowledge.v1.service.create_policy_request","modelName":"knowledge_v1_service_create_policy_request","properties":{"description":{"description":"The description of the policy.","type":"string"},"id":{"type":"string","pattern":"^aia_plcy_.+$","description":"The Policy ID."},"name":{"description":"The name of the policy.","type":"string"},"policy_details":{},"type":{"description":"The description of the policy.","type":"string"}}},"type":{"description":"The type of the knowledge source.","type":"string"},"embedding_model":{"description":"The embedding model to be used for the knowledge source. It's required for 'Database' type but disallowed for other types.","type":"string"}}},"encodingType":"application/json","conditionalParameterMap":{}}
```

From the API, you can create the following type of Knowledge sources: `Web`, `Text`, and `File`.

### Crawl a website

Give Agent Copilot a publicly accessible URL to index information from.

Crawl a website

```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 createKnowledge() {
  const knowledge = await client.knowledge.v1.knowledge.create({
    name: "name",
    type: "Web",
    description: "Web description",
    knowledge_source_details: {
      source: "https://twilio.com",
    },
  });

  console.log(knowledge.description);
}

createKnowledge();
```

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

# 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)

knowledge = client.knowledge.v1.knowledge.create(
    knowledge_v1_service_create_knowledge_request=KnowledgeList.KnowledgeV1ServiceCreateKnowledgeRequest(
        {
            "name": "name",
            "type": "Web",
            "description": "Web description",
            "knowledge_source_details": {"source": "https://twilio.com"},
        }
    )
)

print(knowledge.description)
```

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

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

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 knowledge = await KnowledgeResource.CreateAsync(
            knowledgeV1ServiceCreateKnowledgeRequest: new KnowledgeResource
                .KnowledgeV1ServiceCreateKnowledgeRequest.Builder()
                .WithName("name")
                .WithType("Web")
                .WithDescription("Web description")
                .WithKnowledgeSourceDetails(
                    new Dictionary<string, Object>() { { "source", "https://twilio.com" } })
                .Build());

        Console.WriteLine(knowledge.Description);
    }
}
```

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

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;

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);

        Knowledge.KnowledgeV1ServiceCreateKnowledgeRequest knowledgeV1ServiceCreateKnowledgeRequest =
            new Knowledge.KnowledgeV1ServiceCreateKnowledgeRequest();
        knowledgeV1ServiceCreateKnowledgeRequest.setName("name");
        knowledgeV1ServiceCreateKnowledgeRequest.setType("Web");
        knowledgeV1ServiceCreateKnowledgeRequest.setDescription("Web description");
        knowledgeV1ServiceCreateKnowledgeRequest.setKnowledgeSourceDetails(new HashMap<String, Object>() {
            {
                put("source", "https://twilio.com");
            }
        });

        Knowledge knowledge = Knowledge.creator(knowledgeV1ServiceCreateKnowledgeRequest).create();

        System.out.println(knowledge.getDescription());
    }
}
```

```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.CreateKnowledgeParams{}
	params.SetKnowledgeV1ServiceCreateKnowledgeRequest(knowledge.knowledge_v1_service_create_knowledge_request{
		Name:        "name",
		Type:        "Web",
		Description: "Web description",
		KnowledgeSourceDetails: knowledge.knowledge_v1_service_create_knowledge_request{
			Source: "https://twilio.com",
		},
	})

	resp, err := client.KnowledgeV1.CreateKnowledge(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(resp.Description)
	}
}
```

```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;
use Twilio\Rest\Knowledge\V1\KnowledgeModels;

// 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);

$knowledge = $twilio->knowledge->v1->knowledge->create(
    KnowledgeModels::createKnowledgeV1ServiceCreateKnowledgeRequest([
        "name" => "name",
        "type" => "Web",
        "description" => "Web description",
        "knowledgeSourceDetails" => [
            "source" => "https://twilio.com",
        ],
    ])
);

print $knowledge->description;
```

```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)

knowledge = @client
            .knowledge
            .v1
            .knowledge
            .create(
              knowledge_v1_service_create_knowledge_request: {
                'name' => 'name',
                'type' => 'Web',
                'description' => 'Web description',
                'knowledge_source_details' => {
                  'source' => 'https://twilio.com'
                }
              }
            )

puts knowledge.description
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
KNOWLEDGE_V1_SERVICE_CREATE_KNOWLEDGE_REQUEST_OBJ=$(cat << EOF
{
  "name": "name",
  "type": "Web",
  "description": "Web description",
  "knowledge_source_details": {
    "source": "https://twilio.com"
  }
}
EOF
)
curl -X POST "https://knowledge.twilio.com/v1/Knowledge" \
--json "$KNOWLEDGE_V1_SERVICE_CREATE_KNOWLEDGE_REQUEST_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

### Upload text

Provide plain text for Agent Copilot.

Upload text

```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 createKnowledge() {
  const knowledge = await client.knowledge.v1.knowledge.create({
    name: "Help center article",
    type: "Text",
    description: "Text description",
    knowledge_source_details: {
      content: "Details of text source",
    },
  });

  console.log(knowledge.description);
}

createKnowledge();
```

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

# 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)

knowledge = client.knowledge.v1.knowledge.create(
    knowledge_v1_service_create_knowledge_request=KnowledgeList.KnowledgeV1ServiceCreateKnowledgeRequest(
        {
            "name": "Help center article",
            "type": "Text",
            "description": "Text description",
            "knowledge_source_details": {"content": "Details of text source"},
        }
    )
)

print(knowledge.description)
```

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

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

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 knowledge = await KnowledgeResource.CreateAsync(
            knowledgeV1ServiceCreateKnowledgeRequest: new KnowledgeResource
                .KnowledgeV1ServiceCreateKnowledgeRequest.Builder()
                .WithName("Help center article")
                .WithType("Text")
                .WithDescription("Text description")
                .WithKnowledgeSourceDetails(
                    new Dictionary<string, Object>() { { "content", "Details of text source" } })
                .Build());

        Console.WriteLine(knowledge.Description);
    }
}
```

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

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;

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);

        Knowledge.KnowledgeV1ServiceCreateKnowledgeRequest knowledgeV1ServiceCreateKnowledgeRequest =
            new Knowledge.KnowledgeV1ServiceCreateKnowledgeRequest();
        knowledgeV1ServiceCreateKnowledgeRequest.setName("Help center article");
        knowledgeV1ServiceCreateKnowledgeRequest.setType("Text");
        knowledgeV1ServiceCreateKnowledgeRequest.setDescription("Text description");
        knowledgeV1ServiceCreateKnowledgeRequest.setKnowledgeSourceDetails(new HashMap<String, Object>() {
            {
                put("content", "Details of text source");
            }
        });

        Knowledge knowledge = Knowledge.creator(knowledgeV1ServiceCreateKnowledgeRequest).create();

        System.out.println(knowledge.getDescription());
    }
}
```

```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.CreateKnowledgeParams{}
	params.SetKnowledgeV1ServiceCreateKnowledgeRequest(knowledge.knowledge_v1_service_create_knowledge_request{
		Name:        "Help center article",
		Type:        "Text",
		Description: "Text description",
		KnowledgeSourceDetails: knowledge.knowledge_v1_service_create_knowledge_request{
			Content: "Details of text source",
		},
	})

	resp, err := client.KnowledgeV1.CreateKnowledge(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(resp.Description)
	}
}
```

```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;
use Twilio\Rest\Knowledge\V1\KnowledgeModels;

// 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);

$knowledge = $twilio->knowledge->v1->knowledge->create(
    KnowledgeModels::createKnowledgeV1ServiceCreateKnowledgeRequest([
        "name" => "Help center article",
        "type" => "Text",
        "description" => "Text description",
        "knowledgeSourceDetails" => [
            "content" => "Details of text source",
        ],
    ])
);

print $knowledge->description;
```

```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)

knowledge = @client
            .knowledge
            .v1
            .knowledge
            .create(
              knowledge_v1_service_create_knowledge_request: {
                'name' => 'Help center article',
                'type' => 'Text',
                'description' => 'Text description',
                'knowledge_source_details' => {
                  'content' => 'Details of text source'
                }
              }
            )

puts knowledge.description
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
KNOWLEDGE_V1_SERVICE_CREATE_KNOWLEDGE_REQUEST_OBJ=$(cat << EOF
{
  "name": "Help center article",
  "type": "Text",
  "description": "Text description",
  "knowledge_source_details": {
    "content": "Details of text source"
  }
}
EOF
)
curl -X POST "https://knowledge.twilio.com/v1/Knowledge" \
--json "$KNOWLEDGE_V1_SERVICE_CREATE_KNOWLEDGE_REQUEST_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

### Upload a file

Upload a file for Agent Copilot to reference.

Upload a file

```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 createKnowledge() {
  const knowledge = await client.knowledge.v1.knowledge.create({
    name: "My PDF",
    type: "File",
    description: "Use this for a PDF file",
    knowledge_source_details: {
      content_type: "application/pdf",
      content_url: "https://example.com/myfile.pdf",
    },
  });

  console.log(knowledge.description);
}

createKnowledge();
```

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

# 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)

knowledge = client.knowledge.v1.knowledge.create(
    knowledge_v1_service_create_knowledge_request=KnowledgeList.KnowledgeV1ServiceCreateKnowledgeRequest(
        {
            "name": "My PDF",
            "type": "File",
            "description": "Use this for a PDF file",
            "knowledge_source_details": {
                "content_type": "application/pdf",
                "content_url": "https://example.com/myfile.pdf",
            },
        }
    )
)

print(knowledge.description)
```

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

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

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 knowledge = await KnowledgeResource.CreateAsync(
            knowledgeV1ServiceCreateKnowledgeRequest: new KnowledgeResource
                .KnowledgeV1ServiceCreateKnowledgeRequest.Builder()
                .WithName("My PDF")
                .WithType("File")
                .WithDescription("Use this for a PDF file")
                .WithKnowledgeSourceDetails(new Dictionary<string, Object>() {
                    { "content_type", "application/pdf" },
                    { "content_url", "https://example.com/myfile.pdf" }
                })
                .Build());

        Console.WriteLine(knowledge.Description);
    }
}
```

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

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;

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);

        Knowledge.KnowledgeV1ServiceCreateKnowledgeRequest knowledgeV1ServiceCreateKnowledgeRequest =
            new Knowledge.KnowledgeV1ServiceCreateKnowledgeRequest();
        knowledgeV1ServiceCreateKnowledgeRequest.setName("My PDF");
        knowledgeV1ServiceCreateKnowledgeRequest.setType("File");
        knowledgeV1ServiceCreateKnowledgeRequest.setDescription("Use this for a PDF file");
        knowledgeV1ServiceCreateKnowledgeRequest.setKnowledgeSourceDetails(new HashMap<String, Object>() {
            {
                put("content_type", "application/pdf");
                put("content_url", "https://example.com/myfile.pdf");
            }
        });

        Knowledge knowledge = Knowledge.creator(knowledgeV1ServiceCreateKnowledgeRequest).create();

        System.out.println(knowledge.getDescription());
    }
}
```

```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.CreateKnowledgeParams{}
	params.SetKnowledgeV1ServiceCreateKnowledgeRequest(knowledge.knowledge_v1_service_create_knowledge_request{
		Name:        "My PDF",
		Type:        "File",
		Description: "Use this for a PDF file",
		KnowledgeSourceDetails: knowledge.knowledge_v1_service_create_knowledge_request{
			ContentType: "application/pdf",
			ContentUrl:  "https://example.com/myfile.pdf",
		},
	})

	resp, err := client.KnowledgeV1.CreateKnowledge(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(resp.Description)
	}
}
```

```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;
use Twilio\Rest\Knowledge\V1\KnowledgeModels;

// 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);

$knowledge = $twilio->knowledge->v1->knowledge->create(
    KnowledgeModels::createKnowledgeV1ServiceCreateKnowledgeRequest([
        "name" => "My PDF",
        "type" => "File",
        "description" => "Use this for a PDF file",
        "knowledgeSourceDetails" => [
            "content_type" => "application/pdf",
            "content_url" => "https://example.com/myfile.pdf",
        ],
    ])
);

print $knowledge->description;
```

```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)

knowledge = @client
            .knowledge
            .v1
            .knowledge
            .create(
              knowledge_v1_service_create_knowledge_request: {
                'name' => 'My PDF',
                'type' => 'File',
                'description' => 'Use this for a PDF file',
                'knowledge_source_details' => {
                  'content_type' => 'application/pdf',
                  'content_url' => 'https://example.com/myfile.pdf'
                }
              }
            )

puts knowledge.description
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
KNOWLEDGE_V1_SERVICE_CREATE_KNOWLEDGE_REQUEST_OBJ=$(cat << EOF
{
  "name": "My PDF",
  "type": "File",
  "description": "Use this for a PDF file",
  "knowledge_source_details": {
    "content_type": "application/pdf",
    "content_url": "https://example.com/myfile.pdf"
  }
}
EOF
)
curl -X POST "https://knowledge.twilio.com/v1/Knowledge" \
--json "$KNOWLEDGE_V1_SERVICE_CREATE_KNOWLEDGE_REQUEST_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Get a Knowledge source

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

### Path parameters

```json
[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}]
```

### Get a Knowledge source

Fetch details about a single Knowledge source.

Get a 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 fetchKnowledge() {
  const knowledge = await client.knowledge.v1.knowledge("id").fetch();

  console.log(knowledge.description);
}

fetchKnowledge();
```

```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)

knowledge = client.knowledge.v1.knowledge("id").fetch()

print(knowledge.description)
```

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

using System;
using Twilio;
using Twilio.Rest.Knowledge.V1;
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 knowledge = await KnowledgeResource.FetchAsync(pathId: "id");

        Console.WriteLine(knowledge.Description);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;

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);
        Knowledge knowledge = Knowledge.fetcher("id").fetch();

        System.out.println(knowledge.getDescription());
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"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()

	resp, err := client.KnowledgeV1.FetchKnowledge("id")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(resp.Description)
	}
}
```

```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);

$knowledge = $twilio->knowledge->v1->knowledge("id")->fetch();

print $knowledge->description;
```

```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)

knowledge = @client
            .knowledge
            .v1
            .knowledge('id')
            .fetch

puts knowledge.description
```

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

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

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

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2009-07-06T20:30:00Z",
  "date_updated": "2009-07-06T20:30:00Z",
  "description": "description",
  "embedding_model": "embedding_model",
  "id": "id",
  "knowledge_source_details": {},
  "name": "Miss Christine Morgan",
  "status": "status",
  "type": "type",
  "url": "https://www.example.com"
}
```

### Fetch status of a Knowledge source

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

When you create a Knowledge source, Twilio processes the Knowledge so it's accessible to Agent Copilot.
You can fetch the **status** of processing for a given Knowledge source.

Get the status of a 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 fetchKnowledgeStatus() {
  const knowledgeStatus = await client.knowledge.v1
    .knowledge("id")
    .knowledgeStatus()
    .fetch();

  console.log(knowledgeStatus.accountSid);
}

fetchKnowledgeStatus();
```

```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)

knowledge_status = (
    client.knowledge.v1.knowledge("id").knowledge_status().fetch()
)

print(knowledge_status.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 knowledgeStatus = await KnowledgeStatusResource.FetchAsync(pathId: "id");

        Console.WriteLine(knowledgeStatus.AccountSid);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.knowledge.KnowledgeStatus;

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);
        KnowledgeStatus knowledgeStatus = KnowledgeStatus.fetcher("id").fetch();

        System.out.println(knowledgeStatus.getAccountSid());
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"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()

	resp, err := client.KnowledgeV1.FetchKnowledgeStatus("id")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(resp.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);

$knowledge_status = $twilio->knowledge->v1
    ->knowledge("id")
    ->knowledgeStatus()
    ->fetch();

print $knowledge_status->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)

knowledge_status = @client
                   .knowledge
                   .v1
                   .knowledge('id')
                   .knowledge_status
                   .fetch

puts knowledge_status.account_sid
```

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

twilio api:knowledge:v1:knowledge:status:fetch \
   --id id
```

```bash
curl -X GET "https://knowledge.twilio.com/v1/Knowledge/id/Status" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_updated": "2009-07-06T20:30:00Z",
  "last_status": "last_status",
  "status": "status"
}
```

## List all knowledge

`GET https://knowledge.twilio.com/v1/Knowledge`

### Query parameters

```json
[{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"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"}},{"name":"Tags","in":"query","description":"Json array of tag and value pairs for tag filtering.","schema":{"type":"string"}}]
```

List multiple Knowledges

```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 listKnowledge() {
  const knowledge = await client.knowledge.v1.knowledge.list({ limit: 20 });

  knowledge.forEach((k) => console.log(k.description));
}

listKnowledge();
```

```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)

knowledge = client.knowledge.v1.knowledge.list(limit=20)

for record in knowledge:
    print(record.description)
```

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

using System;
using Twilio;
using Twilio.Rest.Knowledge.V1;
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 knowledge = await KnowledgeResource.ReadAsync(limit: 20);

        foreach (var record in knowledge) {
            Console.WriteLine(record.Description);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;
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<Knowledge> knowledge = Knowledge.reader().limit(20).read();

        for (Knowledge record : knowledge) {
            System.out.println(record.getDescription());
        }
    }
}
```

```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.ListKnowledgeParams{}
	params.SetLimit(20)

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

```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);

$knowledge = $twilio->knowledge->v1->knowledge->read([], 20);

foreach ($knowledge as $record) {
    print $record->description;
}
```

```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)

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

knowledge.each do |record|
   puts record.description
end
```

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

twilio api:knowledge:v1:knowledge:list
```

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

```json
{
  "knowledge": [
    {
      "description": "description",
      "id": "aia_know_#",
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "knowledge_source_details": {},
      "name": "name",
      "status": "status",
      "type": "type",
      "url": "https://www.example.com",
      "embedding_model": "embedding_model",
      "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"
  }
}
```

## Update knowledge

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

### Path parameters

```json
[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}]
```

### Request body parameters

```json
{"schema":{"type":"object","refName":"knowledge.v1.service.update_knowledge_request","modelName":"knowledge_v1_service_update_knowledge_request","additionalProperties":false,"properties":{"description":{"description":"The description of the knowledge source.","type":"string"},"knowledge_source_details":{"description":"The details of the knowledge source based on the type.","type":"object"},"name":{"description":"The name of the knowledge source.","type":"string"},"policy":{"description":"The policy associated with the knowledge source.","type":"object","required":["policy_details"],"refName":"knowledge.v1.service.create_policy_request","modelName":"knowledge_v1_service_create_policy_request","properties":{"description":{"description":"The description of the policy.","type":"string"},"id":{"type":"string","pattern":"^aia_plcy_.+$","description":"The Policy ID."},"name":{"description":"The name of the policy.","type":"string"},"policy_details":{},"type":{"description":"The description of the policy.","type":"string"}}},"type":{"description":"The description of the knowledge source.","type":"string"},"embedding_model":{"description":"The embedding model to be used for the knowledge source. It's only applicable to 'Database' type.","type":"string"}}},"encodingType":"application/json","conditionalParameterMap":{}}
```

Update a Knowledge

```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 updateKnowledge() {
  const knowledge = await client.knowledge.v1.knowledge("id").update({
    description: "description",
  });

  console.log(knowledge.description);
}

updateKnowledge();
```

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

# 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)

knowledge = client.knowledge.v1.knowledge("id").update(
    knowledge_v1_service_update_knowledge_request=KnowledgeList.KnowledgeV1ServiceUpdateKnowledgeRequest(
        {"description": "description"}
    )
)

print(knowledge.description)
```

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

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

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 knowledge = await KnowledgeResource.UpdateAsync(
            knowledgeV1ServiceUpdateKnowledgeRequest: new KnowledgeResource
                .KnowledgeV1ServiceUpdateKnowledgeRequest.Builder()
                .WithDescription("description")
                .Build(),
            pathId: "id");

        Console.WriteLine(knowledge.Description);
    }
}
```

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

import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;

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);

        Knowledge.KnowledgeV1ServiceUpdateKnowledgeRequest knowledgeV1ServiceUpdateKnowledgeRequest =
            new Knowledge.KnowledgeV1ServiceUpdateKnowledgeRequest();
        knowledgeV1ServiceUpdateKnowledgeRequest.setDescription("description");

        Knowledge knowledge = Knowledge.updater("id", knowledgeV1ServiceUpdateKnowledgeRequest).update();

        System.out.println(knowledge.getDescription());
    }
}
```

```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.UpdateKnowledgeParams{}
	params.SetKnowledgeV1ServiceUpdateKnowledgeRequest(knowledge.knowledge_v1_service_update_knowledge_request{
		Description: "description",
	})

	resp, err := client.KnowledgeV1.UpdateKnowledge("id",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(resp.Description)
	}
}
```

```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;
use Twilio\Rest\Knowledge\V1\KnowledgeModels;

// 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);

$knowledge = $twilio->knowledge->v1->knowledge("id")->update(
    KnowledgeModels::createKnowledgeV1ServiceUpdateKnowledgeRequest([
        "description" => "description",
    ])
);

print $knowledge->description;
```

```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)

knowledge = @client
            .knowledge
            .v1
            .knowledge('id')
            .update(
              knowledge_v1_service_update_knowledge_request: {
                'description' => 'description'
              }
            )

puts knowledge.description
```

```bash
# This endpoint is not currently supported by the Twilio CLI. You can open an issue to request it on https://github.com/twilio/twilio-cli/issues
  # For an alternative low-code solution, check out https://www.twilio.com/docs/openapi/using-twilio-postman-collections
```

```bash
KNOWLEDGE_V1_SERVICE_UPDATE_KNOWLEDGE_REQUEST_OBJ=$(cat << EOF
{
  "description": "description"
}
EOF
)
curl -X PUT "https://knowledge.twilio.com/v1/Knowledge/id" \
--json "$KNOWLEDGE_V1_SERVICE_UPDATE_KNOWLEDGE_REQUEST_OBJ" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2009-07-06T20:30:00Z",
  "date_updated": "2009-07-06T20:30:00Z",
  "description": "description",
  "embedding_model": "embedding_model",
  "id": "id",
  "knowledge_source_details": {},
  "name": "Miss Christine Morgan",
  "status": "status",
  "type": "type",
  "url": "https://www.example.com"
}
```

## Delete knowledge

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

### Path parameters

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

Delete a Knowledge

```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 deleteKnowledge() {
  await client.knowledge.v1.knowledge("id").remove();
}

deleteKnowledge();
```

```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)

client.knowledge.v1.knowledge("id").delete()
```

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

using System;
using Twilio;
using Twilio.Rest.Knowledge.V1;
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);

        await KnowledgeResource.DeleteAsync(pathId: "id");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.knowledge.v1.Knowledge;

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);
        Knowledge.deleter("id").delete();
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"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()

	err := client.KnowledgeV1.DeleteKnowledge("id")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

```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);

$twilio->knowledge->v1->knowledge("id")->delete();
```

```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)

@client
  .knowledge
  .v1
  .knowledge('id')
  .delete
```

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

twilio api:knowledge:v1:knowledge:remove \
   --id id
```

```bash
curl -X DELETE "https://knowledge.twilio.com/v1/Knowledge/id" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
