NAME

Twilio::Rest::Knowledge::V2::Knowledge - The Knowledge resource

SYNOPSIS

my $client = Twilio::Rest::Client->new($account_sid, $auth_token);

my $knowledge = $client->knowledge->v2->knowledge($kb_id)->create(\%body);
for my $knowledge ($client->knowledge->v2->knowledge($kb_id)->read({}, 20)) {
  ...
}
my $knowledge = $client->knowledge->v2->knowledge($kb_id, $knowledge_id)->fetch;
$client->knowledge->v2->knowledge($kb_id, $knowledge_id)->update(\%body, \%options);
$client->knowledge->v2->knowledge($kb_id, $knowledge_id)->delete;

DESCRIPTION

This file holds KnowledgeList, KnowledgePage, KnowledgeContext, KnowledgeInstance and UpdateKnowledge202ResponseInstance. Methods that make a request throw Twilio::Exceptions::RestException on an error response.

KnowledgeList

Returned by $client->knowledge->v2->knowledge($kb_id). See also Twilio::ListResource.

create

my $knowledge = $client->knowledge->v2->knowledge($kb_id)->create(\%body);

Create a new knowledge source from various data sources such as web content, files, or raw text. The knowledge source will be processed and indexed to enable semantic search and retrieval. ## Best practices To maximize the effectiveness of Knowledge, consider the following best practices: Assess and optimize content: Regularly evaluate your existing Knowledge sources for accuracy, relevance, and coverage. Identify any gaps or outdated information that could hinder the Assistant's performance. Simplify and structure content: Ensure that the content is clear and concise. Use headings, bullet points, and metadata to make information straightforward to navigate for both the AI Assistant and your users. Prioritize high-impact content: Focus on updating and maintaining content that is frequently accessed or critical to customer interactions. Consider using analytics to determine which Knowledge entries are most valuable. Returns a KnowledgeInstance.

%body is sent as JSON. It takes the names Twilio's API documentation uses.

Its fields are:

description

A detailed description of the knowledge source and when to use it. This helps provide context about the content and its intended purpose.

name

Required. The name of the knowledge source.

source

No description in the specification.

read

my @records = $client->knowledge->v2->knowledge($kb_id)->read(\%options, $limit, $page_size);

Retrieve a paginated list of all knowledge sources for a specific knowledge base. Knowledge sources represent unstructured data sources such as documents, websites, or text content that can be used for context and information retrieval. Returns the records as a list, fetching as many pages as it needs.

The options are:

page

The page index. This value is simply for client state.

stream

my $stream = $client->knowledge->v2->knowledge($kb_id)->stream(\%options, $limit, $page_size);

Takes the same arguments as "read", and returns a Twilio::Stream.

page

my $page = $client->knowledge->v2->knowledge($kb_id)->page(\%options, $page_size, $page_token);

Fetches one page, and returns a Twilio::TokenPaginationPage. This API pages by token, so there is no page number.

get_page

my $page = $client->knowledge->v2->knowledge($kb_id)->get_page($url);

Fetches the page at a URL given by Twilio.

get_context

my $context = $client->knowledge->v2->knowledge($kb_id)->get_context($knowledge_id);

Returns a KnowledgeContext, and makes no request.

KnowledgePage

A Twilio::Page of KnowledgeInstance objects.

records_key

build_instance

Used by Twilio::Page.

KnowledgeContext

Returned by $client->knowledge->v2->knowledge($kb_id, $knowledge_id). It makes no request until one of these methods is called.

fetch

my $knowledge = $client->knowledge->v2->knowledge($kb_id, $knowledge_id)->fetch;

Fetch detailed information about a specific knowledge source by its ID. This returns the complete knowledge source object including processing status, source details, and configuration information. Returns a KnowledgeInstance.

update

my $knowledge = $client->knowledge->v2->knowledge($kb_id, $knowledge_id)->update(\%body, \%options);

Partially update mutable fields of an existing knowledge source such as name, description, tags, or source-specific configuration. Only the fields provided in the request body will be updated. Some changes (e.g., KnowledgeSourceTypes) may trigger asynchronous reprocessing of the underlying content. Fields omitted from the request remain unchanged. Immutable fields (id, type, status, url, createdAt, updatedAt) cannot be modified directly. ## Refresh ## To request reprocessing without changing fields, pass the query parameter refresh=true. When refresh=true is provided, the server will re-queue processing for this knowledge resource (transitioning the persisted status to QUEUED) and return 202 Accepted. This query parameter is idempotent while the resource is already QUEUED or PROCESSING. Returns a UpdateKnowledge202ResponseInstance when Twilio answers 202, and a KnowledgeInstance otherwise.

%body is sent as JSON. It can be left out. When given, it takes the names Twilio's API documentation uses.

Its fields are:

description

A detailed description of the knowledge source and when to use it. This helps provide context about the content and its intended purpose.

name

Required. The name of the knowledge source.

source

No description in the specification.

The options are:

refresh

When true, re-queues processing for this knowledge resource. Idempotent while the resource is already QUEUED or PROCESSING.

delete

$client->knowledge->v2->knowledge($kb_id, $knowledge_id)->delete;

Permanently delete knowledge source and all its associated data, including processed chunks and embeddings. This action cannot be undone. The knowledge resource will no longer be available for search or retrieval operations. Returns true.

KnowledgeInstance

See also Twilio::InstanceResource.

It has fetch, update and delete, which work as they do on the context.

Its fields are:

created_at

The date and time in GMT when the Knowledge was created specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

description

A detailed description of the knowledge source and when to use it. This helps provide context about the content and its intended purpose.

id

No description in the specification.

name

The name of the knowledge source.

source

No description in the specification.

status

The status of processing the knowledge source ('SCHEDULED', 'QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED'). One of SCHEDULED, QUEUED, PROCESSING, COMPLETED or FAILED.

updated_at

The date and time in GMT when the Knowledge was last updated specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

UpdateKnowledge202ResponseInstance

Returned by update, for an answer that is not a Knowledge. See also Twilio::InstanceResource.

Its fields are:

message

No description in the specification.

CONSTRUCTORS

new

Objects here come from the methods above, so there is no need to call new directly.

LICENSE

Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.