Belgelere geç
PHP

$client->knowledge

Bu ad alanındaki her yöntem: imzası, parametreleri, döndürdüğü değer ve bir örnek.

Yöntemler

The notes, files and web pages the AI uses when it writes replies, drafts email and answers in the assistant, each kept for the whole workspace, one domain or one address: list and search them, add a note, a link or a file, change, read again and delete them, and see the levels and how much the plan allows. Review the notes the AI suggests and the questions nothing answers, settle duplicate and conflict flags, keep a site, sitemap, feed or Zendesk help center in step with connectors, draft a note from a conversation, and read how often the AI used it.

knowledge->list

List one page of the knowledge base

Kapsamlarknowledge:readSonuçlarda sayfa sayfa ilerler
İmza
list(    ?string $scope = null,    ?string $level = null,    ?string $kind = null,    ?string $status = null,    ?bool $pinned = null,    ?string $q = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Page

Returns one page of the knowledge base, newest first: the notes, files and web pages the AI uses when it writes replies, drafts email and answers in the assistant. Each item says where it sits, whether the AI can use it yet and how much text was read from it. knowledge->listAll collects every page and knowledge->iterate walks them lazily.

Every item sits at one level, its scope: an empty string for the whole workspace, @ and a domain for everything on that domain (@acme.com), or one address ([email protected]). The AI writing for an address reads that address, then its domain, then the whole workspace, the most specific first. level names the kind of level, workspace, domain or address.

status is queued or processing while the text is read and indexed, ready once the AI can use it, and failed with a failure when it could not be read. A key or an app limited to particular addresses sees the whole-workspace items and the items at its addresses and at their domains.

Each item also says how the AI uses it: uses counts the times it came up in a reply suggestion, a draft, the assistant or a search, with lastUsedAt the latest, and flags counts the open duplicate and conflict flags that name it. A link read again on a schedule has refreshDays and nextRefreshAt, a page kept by a connector names it in connectorId, and a note saved from a conversation names it in threadId.

Parametreler

scopestring

Keeps the items at exactly this level: @ and a domain such as @acme.com, or one address. An empty string is not sent, so ask for the whole-workspace items with level: 'workspace'.

levelstring

Keeps one kind of level: workspace, domain or address, also in OpenEmail\Constants\KnowledgeLevels.

kindstring

Keeps one kind of item: note, file or link, also in OpenEmail\Constants\KnowledgeKinds.

statusstring

Keeps one status: queued, processing, ready or failed, also in OpenEmail\Constants\KnowledgeStatuses.

pinnedbool

true keeps the pinned notes and false everything else.

qstring

Words in the title, the file name or the link, matched without regard to case or accents.

limitint

Page size, from 1 to 100. The server defaults to 50.

cursorstring

The nextCursor of the previous page. Leave it out for the first page.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

A Page of item arrays, with items, hasMore and nextCursor. Each item has id, kind, scope, level, title, url, fileName, mimeType, sizeBytes, pinned, status, failure, chunks, chars, origin, createdBy, createdAt, updatedAt, indexedAt, refreshDays, nextRefreshAt, connectorId, threadId, uses, lastUsedAt and flags.

Örnek

use OpenEmail\Constants\KnowledgeKinds;use OpenEmail\Constants\KnowledgeLevels; $page = $client->knowledge->list(level: KnowledgeLevels::DOMAIN, kind: KnowledgeKinds::FILE); foreach ($page as $item) {    echo $item['scope'], ' ', $item['title'], ' ', $item['status'], PHP_EOL;}

Notlar

  • Needs knowledge:read, which knowledge:write includes.

  • The cursor is opaque. One this list did not hand out is a 400 invalid_cursor. A scope that is neither a domain nor an address is a 422 invalid_knowledge_scope, and a level the key cannot see lists nothing.

Şurada da var

API
GET /knowledge
TypeScript
knowledge.list()
Python
knowledge.list()
Ruby
knowledge.list
CLI
openemail knowledge list

knowledge->listAll

Collect every knowledge item into one array

Kapsamlarknowledge:readSonuçlarda sayfa sayfa ilerler
İmza
listAll(    ?string $scope = null,    ?string $level = null,    ?string $kind = null,    ?string $status = null,    ?bool $pinned = null,    ?string $q = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Walks every page of knowledge->list and returns every item in one array, newest first. One request per page, with the same filters on each.

Parametreler

scopestring

Keeps the items at exactly this level: @ and a domain such as @acme.com, or one address. An empty string is not sent, so ask for the whole-workspace items with level: 'workspace'.

levelstring

Keeps one kind of level: workspace, domain or address, also in OpenEmail\Constants\KnowledgeLevels.

kindstring

Keeps one kind of item: note, file or link, also in OpenEmail\Constants\KnowledgeKinds.

statusstring

Keeps one status: queued, processing, ready or failed, also in OpenEmail\Constants\KnowledgeStatuses.

pinnedbool

true keeps the pinned notes and false everything else.

qstring

Words in the title, the file name or the link, matched without regard to case or accents.

limitint

Page size for each request, from 1 to 100. The server defaults to 50.

cursorstring

Starts the walk after this cursor instead of the first page.

apiKeystring

Overrides the client's API key for every page of this walk.

Döndürür

A list of item arrays holding every item, each with the fields knowledge->list returns.

Örnek

use OpenEmail\Constants\KnowledgeStatuses; $failed = $client->knowledge->listAll(status: KnowledgeStatuses::FAILED); foreach ($failed as $item) {    echo $item['title'], ': ', $item['failure'] ?? 'unknown', PHP_EOL;}

Notlar

  • If any page fails, the exception is thrown and the items already fetched are discarded.

Şurada da var

API
GET /knowledge
TypeScript
knowledge.listAll()
Python
knowledge.list_all()
Ruby
knowledge.list_all

knowledge->iterate

Stream the knowledge items one at a time

Kapsamlarknowledge:readSonuçlarda sayfa sayfa ilerler
İmza
iterate(    ?string $scope = null,    ?string $level = null,    ?string $kind = null,    ?string $status = null,    ?bool $pinned = null,    ?string $q = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields one item at a time, newest first, and requests the next page only once the current one is used up. Nothing is fetched until the loop starts, and breaking out of the foreach stops the requests.

Parametreler

scopestring

Keeps the items at exactly this level: @ and a domain such as @acme.com, or one address. An empty string is not sent, so ask for the whole-workspace items with level: 'workspace'.

levelstring

Keeps one kind of level: workspace, domain or address, also in OpenEmail\Constants\KnowledgeLevels.

kindstring

Keeps one kind of item: note, file or link, also in OpenEmail\Constants\KnowledgeKinds.

statusstring

Keeps one status: queued, processing, ready or failed, also in OpenEmail\Constants\KnowledgeStatuses.

pinnedbool

true keeps the pinned notes and false everything else.

qstring

Words in the title, the file name or the link, matched without regard to case or accents.

limitint

Page size for each request, from 1 to 100. The server defaults to 50.

cursorstring

Starts the walk after this cursor instead of the first page.

apiKeystring

Overrides the client's API key for every page of this walk.

Döndürür

A Generator that yields one item array per step.

Örnek

foreach ($client->knowledge->iterate(pinned: true) as $item) {    echo $item['scope'] === '' ? 'whole workspace' : $item['scope'], ' ', $item['title'], PHP_EOL;}

Notlar

  • The generator is lazy, so an abandoned loop costs only the pages you consumed.

Şurada da var

API
GET /knowledge
TypeScript
knowledge.iterate()
Python
knowledge.iterate()
Ruby
knowledge.iterate

knowledge->levels

List the levels knowledge can sit at

Kapsamlarknowledge:read
İmza
levels(?string $apiKey = null): array

Returns every level the caller can see: the whole workspace first, then each domain, then each address, with how many items each holds and whether the caller may add and change items there. Pass its scope when you add an item.

A key or an app limited to particular addresses sees the whole workspace, its addresses and their domains. writable is true at the whole workspace only for a caller that reaches every address, at a domain for one that holds the whole domain, and at an address for one that holds that address.

Parametreler

apiKeystring

Overrides the client's API key for this call only.

Döndürür

A list of arrays, each with scope, level, writable and items.

Örnek

$levels = $client->knowledge->levels(); foreach ($levels as $level) {    if ($level['writable']) {        echo $level['scope'] === '' ? 'whole workspace' : $level['scope'], ': ', $level['items'], ' items', PHP_EOL;    }}

Notlar

  • Needs knowledge:read. A removed address is not a level.

Şurada da var

API
GET /knowledge/levels
TypeScript
knowledge.levels()
Python
knowledge.levels()
Ruby
knowledge.levels
CLI
openemail knowledge levels

knowledge->usage

Read how much of the plan the knowledge base uses

Kapsamlarknowledge:read
İmza
usage(?string $apiKey = null): array

Returns how many items and how many characters of text the workspace keeps in its knowledge base, beside what its plan allows in limits: 50 items and 1,000,000 characters on Free, 500 and 10,000,000 on Starter, 2,000 and 50,000,000 on Business, and 10,000 and 200,000,000 on Enterprise.

An item counts as soon as it is added, and its characters once its text has been read. The numbers are for the whole workspace, whatever the key may reach.

Parametreler

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with plan, sources, chars and limits, which holds sources and chars.

Örnek

$usage = $client->knowledge->usage(); echo $usage['sources'], ' of ', $usage['limits']['sources'], ' items, ', $usage['chars'], ' of ', $usage['limits']['chars'], ' characters', PHP_EOL;

Notlar

  • Needs knowledge:read.

  • Adding an item to a full knowledge base is a 409 knowledge_allowance_reached. A file or a page whose text would pass the allowance once read is kept as failed, with failure set to over_allowance.

Şurada da var

API
GET /knowledge/usage
TypeScript
knowledge.usage()
Python
knowledge.usage()
Ruby
knowledge.usage
CLI
openemail knowledge usage

knowledge->createNote

Add a note to the knowledge base

Kapsamlarknowledge:write
İmza
createNote(array $body, ?string $apiKey = null): array

Saves a note of up to 20,000 characters at one level and returns it. Markdown is kept, and its headings become the headings the passages sit under. A note is usually ready for the AI within a second or two, and queued or processing until then.

A note with pinned set to true goes into every prompt the AI writes at its level, not only when it matches what is being written. The AI reads at most 2,000 characters of pinned notes from each level, so keep them short.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

Parametreler

scopestring

The level: an empty string, or left out, for the whole workspace, @ and a domain such as @acme.com, or one address such as [email protected].

titlestringZorunlu

A short name for the note, at most 200 characters.

bodystringZorunlu

The text, up to 20,000 characters, in Markdown if you like.

pinnedbool

Puts the note into every prompt at its level. Left out, false.

threadIdstring

The conversation the note comes from, such as the one knowledge->draftFromThread read. It is kept on the note as threadId.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the new note, with kind set to note and origin set to api.

Örnek

$note = $client->knowledge->createNote([    'scope' => '@acme.com',    'title' => 'Refunds',    'body' => 'Refunds are paid within 14 days of the return reaching our warehouse.',    'pinned' => true,]); echo $note['id'], ' ', $note['status'], PHP_EOL;

Notlar

  • Needs knowledge:write.

  • A level that is not the workspace, one of its domains or one of its addresses is a 422 invalid_knowledge_scope, and a level outside what the key reaches is a 403 knowledge_scope_not_reached. A full knowledge base is a 409 knowledge_allowance_reached.

  • The SDK does not retry it, because a second attempt after a lost response could save the note twice. Look for it with knowledge->list before trying again.

Şurada da var

API
POST /knowledge/notes
TypeScript
knowledge.createNote()
Python
knowledge.create_note()
Ruby
knowledge.create_note
CLI
openemail knowledge create-note

knowledge->uploadFile

Upload a file to the knowledge base

Kapsamlarknowledge:write
İmza
uploadFile(    mixed $data,    ?string $filename = null,    ?string $contentType = null,    ?string $scope = null,    ?string $title = null,    int|float|null $timeout = null,    ?string $apiKey = null,): array

Stores a document or an image at one level and returns it, queued. Its text is read in the background, and the AI uses it once its status is ready. PDFs, Word documents, spreadsheets (Excel, OpenDocument, Numbers and CSV), OpenDocument text, HTML, XML, Markdown, plain text, JSON and images (JPEG, PNG, WebP and SVG) can be read.

data is a string of bytes, a stream resource, an SplFileInfo or a PSR-7 stream or uploaded file, sent as the request body. The name travels as the filename query parameter, and left out it is the name of the SplFileInfo, the uploaded file or the file a stream was opened on. The type is contentType:, else the media type a PSR-7 uploaded file declares, else the one the extension of the name gives. A document can be up to 20 MB and an image up to 10 MB.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

Parametreler

datastring|resource|SplFileInfo|StreamInterfaceZorunlu

The file: a string of bytes, a stream resource, an SplFileInfo or a PSR-7 stream or uploaded file, not empty, at most 20 MB for a document and 10 MB for an image.

filenamestring

The file name, such as price-list.pdf. Its extension tells the kind of file when the type is generic. Left out, the name of the SplFileInfo, the uploaded file or the file a stream was opened on is used. A string of bytes has no name of its own, and a missing or blank name throws an InvalidArgumentException before anything is sent.

contentTypestring

The MIME type, such as application/pdf. Left out, it comes from the uploaded file or the file extension as above.

scopestring

The level: an empty string, or left out, for the whole workspace, @ and a domain such as @acme.com, or one address such as [email protected].

titlestring

A name for the item, at most 200 characters. Left out, the file name without its extension.

timeoutint|float

How long the upload may take, in seconds. Left out, it is 10 minutes, or the client's timeout when that is longer. 0 waits as long as it takes, and a negative value throws an InvalidArgumentException.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the new file, with kind set to file, its fileName, mimeType and sizeBytes, and status set to queued.

Örnek

$file = $client->knowledge->uploadFile(new \SplFileInfo('report.csv'), scope: '[email protected]', title: 'Price list'); echo $file['id'], ' ', $file['title'], ' ', $file['status'], PHP_EOL;

Notlar

  • Needs knowledge:write.

  • A kind of file that cannot be read is a 422 knowledge_file_unsupported, an empty file a 422 knowledge_file_empty, and a file over the limit a 413 knowledge_file_too_large. A level that is not the workspace, one of its domains or one of its addresses is a 422 invalid_knowledge_scope, and a level outside what the key reaches is a 403 knowledge_scope_not_reached. A full knowledge base is a 409 knowledge_allowance_reached.

  • A file with no text in it ends failed with failure set to empty, and one that could not be turned into text with conversion_failed.

  • The SDK does not retry an upload, because a second attempt after a lost response could store the file twice. Look for it with knowledge->list before trying again.

Şurada da var

API
POST /knowledge/files
TypeScript
knowledge.uploadFile()
Python
knowledge.upload_file()
Ruby
knowledge.upload_file
CLI
openemail knowledge upload-file

knowledge->get

Read one knowledge item and its text

Kapsamlarknowledge:read
İmza
get(string $id, ?string $apiKey = null): array

Returns one item with its text: the body of a note, or in preview the first 20,000 characters read from a file or a page, with previewTruncated true when the text goes on past it. preview is null while a file or a page has not been read yet, and body is null for anything but a note.

Parametreler

idstringZorunlu

The id of the item, kb_ and 24 hex characters, as knowledge->list returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with the fields knowledge->list returns for each item, plus body, preview and previewTruncated.

Örnek

$item = $client->knowledge->get('kb_8c1f4a2b9d7e3f60a5c7b21d'); echo $item['title'], PHP_EOL, $item['body'] ?? $item['preview'] ?? '', PHP_EOL;

Notlar

  • Needs knowledge:read. An unknown id, and an item at a level the key cannot see, answer 404 knowledge_not_found.

Şurada da var

API
GET /knowledge/{id}
TypeScript
knowledge.get()
Python
knowledge.get()
Ruby
knowledge.get
CLI
openemail knowledge get

knowledge->update

Change a knowledge item

Kapsamlarknowledge:write
İmza
update(string $id, array $patch, ?string $apiKey = null): array

Changes the title of an item, the text of a note, the page of a link, how often a link is read again, whether a note is pinned, or its level, and returns the item as it is now. Give at least one field. A changed title, text or link is read and indexed again, so the item goes back to queued, and its previous text stays in use until the new one is ready. Moving an item to another level needs no new reading.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole. Moving an item needs that reach at both levels.

Parametreler

idstringZorunlu

The id of the item, kb_ and 24 hex characters, as knowledge->list returns it.

titlestring

A new name, at most 200 characters.

bodystring

The new text of a note, up to 20,000 characters.

scopestring

The level to move it to: an empty string for the whole workspace, @ and a domain, or one address.

pinnedbool

Whether a note goes into every prompt at its level.

urlstring

The new page of a link, a public http or https address.

refreshDaysint

Reads a link again every 1, 7 or 30 days, counted from now. Null stops that.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the item as it is now, with the fields knowledge->list returns.

Örnek

$item = $client->knowledge->update('kb_8c1f4a2b9d7e3f60a5c7b21d', [    'body' => 'Refunds are paid within 10 days of the return reaching our warehouse.',    'pinned' => true,]); echo $item['status'], ' ', $item['updatedAt'], PHP_EOL;

Notlar

Şurada da var

API
PATCH /knowledge/{id}
TypeScript
knowledge.update()
Python
knowledge.update()
Ruby
knowledge.update
CLI
openemail knowledge update

knowledge->delete

Delete a knowledge item for good

Kapsamlarknowledge:write
İmza
delete(string $id, ?string $apiKey = null): array

Removes an item with its file and every passage read from it, and the AI stops using it at once. There is no undo.

Parametreler

idstringZorunlu

The id of the item, kb_ and 24 hex characters, as knowledge->list returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with object set to knowledge_item, id and deleted set to true.

Örnek

$removed = $client->knowledge->delete('kb_8c1f4a2b9d7e3f60a5c7b21d'); echo $removed['id'], ' deleted: ', $removed['deleted'] ? 'yes' : 'no', PHP_EOL;

Notlar

  • Needs knowledge:write, and reach over the level of the item. An unknown id is a 404 knowledge_not_found.

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

Şurada da var

API
DELETE /knowledge/{id}
TypeScript
knowledge.delete()
Python
knowledge.delete()
Ruby
knowledge.delete
CLI
openemail knowledge delete

knowledge->refresh

Read a knowledge item again

Kapsamlarknowledge:write
İmza
refresh(string $id, ?string $apiKey = null): array

Fetches a link again, reads a file again or indexes a note again, clears any failure and returns the item, back at queued. Use it after a page changed or when an item failed. The previous text stays in use until the new one is ready.

Parametreler

idstringZorunlu

The id of the item, kb_ and 24 hex characters, as knowledge->list returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the item, queued to be read again.

Örnek

$item = $client->knowledge->refresh('kb_8c1f4a2b9d7e3f60a5c7b21d'); echo $item['status'], PHP_EOL;

Notlar

  • Needs knowledge:write, and reach over the level of the item.

  • Reading an item again twice leaves it the same way, so the SDK retries it on network failure and retryable statuses.

Şurada da var

API
POST /knowledge/{id}/refresh
TypeScript
knowledge.refresh()
Python
knowledge.refresh()
Ruby
knowledge.refresh
CLI
openemail knowledge refresh

knowledge->stats

Read how the AI used the knowledge base

Kapsamlarknowledge:read
İmza
stats(?int $days = null, ?string $apiKey = null): array

Returns how the AI used the knowledge base over the last days days, today included, 30 unless you say. uses counts the times a reply suggestion, a draft, the assistant or a search found something in it, and empty the times it looked and found nothing. coverage is uses divided by the two together, from 0 to 1, and 0 when it never looked. bySurface splits uses by where they happened, under the keys compose, reply, chat, tool and search, and series has one entry per day, oldest first, days with nothing included.

topItems lists the items used most, ever, and unusedItems counts the ready items the AI has never used. pendingSuggestions counts the learned notes waiting for review, openQuestions the questions senders asked that nothing answers yet, and openFlags the open duplicate and conflict flags. uses, empty, bySurface and series cover the whole workspace, while the items, suggestions, questions and flags count only what the caller can see.

Parametreler

daysint

How many days back to count, today included, from 1 to 90. The server defaults to 30.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with days, uses, empty, coverage, bySurface, series, topItems, unusedItems, pendingSuggestions, openQuestions and openFlags. Each day in series has day, uses and empty, and each of topItems has id, title, kind, scope, uses and lastUsedAt.

Örnek

$stats = $client->knowledge->stats(days: 7); echo round($stats['coverage'] * 100), '% of lookups found something', PHP_EOL; foreach ($stats['topItems'] as $item) {    echo $item['uses'], ' ', $item['title'], PHP_EOL;}

Notlar

  • Needs knowledge:read. It changes nothing, so the SDK retries it like any other read.

  • A days outside 1 to 90 is a 422 invalid_parameter.

Şurada da var

API
GET /knowledge/stats
TypeScript
knowledge.stats()
Python
knowledge.stats()
Ruby
knowledge.stats
CLI
openemail knowledge stats

knowledge->listSuggestions

List one page of knowledge suggestions and questions

Kapsamlarknowledge:readSonuçlarda sayfa sayfa ilerler
İmza
listSuggestions(    ?string $kind = null,    ?string $status = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Page

Returns one page of what the AI suggests adding to the knowledge base, the most recent first, pending ones unless you ask for another status. knowledge->listAllSuggestions collects every page and knowledge->iterateSuggestions walks them lazily.

A learned suggestion is a note the AI drew from a reply sent from the workspace: it reads the message the reply answers and the reply, and keeps up to three facts that would hold for other people too, at the level of the domain the reply was sent from, or the whole workspace when that domain is not one of its own. Facts the knowledge base already holds are left out, and at most 100 replies a day are read. A question is something a sender asked about the business that neither the conversation nor the knowledge base answers: when the AI suggests replies to an incoming message, it notes up to 3 such questions, at the level of the domain the message arrived at, chosen the same way. Accept a question with its answer and it becomes a note.

The same fact or question again counts up occurrences instead of adding a second suggestion, and one that was dismissed is not suggested again. Both kinds stop while the workspace setting knowledgeLearning is off, which settings->update changes.

Parametreler

kindstring

Keeps one kind: learned for notes drawn from sent replies, or question for questions nothing answers, also in OpenEmail\Constants\KnowledgeSuggestionKinds.

statusstring

Keeps one status: pending, accepted or dismissed, also in OpenEmail\Constants\KnowledgeSuggestionStatuses. Left out, pending.

limitint

Page size, from 1 to 100. The server defaults to 50.

cursorstring

The nextCursor of the previous page. Leave it out for the first page.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

A Page of suggestion arrays, with items, hasMore and nextCursor. Each suggestion has id, kind, status, scope, level, title, body, occurrences, threadId, sourceId, createdAt, updatedAt and decidedAt.

Örnek

use OpenEmail\Constants\KnowledgeSuggestionKinds; $page = $client->knowledge->listSuggestions(kind: KnowledgeSuggestionKinds::QUESTION); foreach ($page as $question) {    echo $question['occurrences'], ' ', $question['title'], PHP_EOL;}

Notlar

  • Needs knowledge:read, which knowledge:write includes.

  • A learned suggestion holds the suggested note in title and body. A question holds the question in title, and its body is null until it is answered. threadId names the conversation it came from most recently, and sourceId the note made from it once it is accepted.

  • A key or an app limited to particular addresses sees the suggestions at the whole workspace, at its addresses and at their domains. The cursor is opaque, and one this list did not hand out is a 400 invalid_cursor.

Şurada da var

API
GET /knowledge/suggestions
TypeScript
knowledge.listSuggestions()
Python
knowledge.list_suggestions()
Ruby
knowledge.list_suggestions
CLI
openemail knowledge list-suggestions

knowledge->listAllSuggestions

Collect every knowledge suggestion into one list

Kapsamlarknowledge:readSonuçlarda sayfa sayfa ilerler
İmza
listAllSuggestions(    ?string $kind = null,    ?string $status = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Walks every page of knowledge->listSuggestions and returns every suggestion or question that matches in one list, the most recent first. One request per page, with the same filters on each.

Parametreler

kindstring

Keeps one kind: learned for notes drawn from sent replies, or question for questions nothing answers, also in OpenEmail\Constants\KnowledgeSuggestionKinds.

statusstring

Keeps one status: pending, accepted or dismissed, also in OpenEmail\Constants\KnowledgeSuggestionStatuses. Left out, pending.

limitint

Page size for each request, from 1 to 100. The server defaults to 50.

cursorstring

Starts the walk after this cursor instead of the first page.

apiKeystring

Overrides the client's API key for every page of this walk.

Döndürür

A list of suggestion arrays holding every suggestion and question that matches, each with the fields knowledge->listSuggestions returns.

Örnek

use OpenEmail\Constants\KnowledgeSuggestionKinds; $questions = $client->knowledge->listAllSuggestions(kind: KnowledgeSuggestionKinds::QUESTION); echo count($questions), ' questions wait for an answer', PHP_EOL;

Notlar

  • If any page fails, the exception is thrown and the suggestions already fetched are discarded.

Şurada da var

API
GET /knowledge/suggestions
TypeScript
knowledge.listAllSuggestions()
Python
knowledge.list_all_suggestions()
Ruby
knowledge.list_all_suggestions

knowledge->iterateSuggestions

Stream the knowledge suggestions one at a time

Kapsamlarknowledge:readSonuçlarda sayfa sayfa ilerler
İmza
iterateSuggestions(    ?string $kind = null,    ?string $status = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields one suggestion or question at a time, the most recent first, and requests the next page only once the current one is used up. Nothing is fetched until the loop starts, and leaving the loop with break stops the requests.

Parametreler

kindstring

Keeps one kind: learned for notes drawn from sent replies, or question for questions nothing answers, also in OpenEmail\Constants\KnowledgeSuggestionKinds.

statusstring

Keeps one status: pending, accepted or dismissed, also in OpenEmail\Constants\KnowledgeSuggestionStatuses. Left out, pending.

limitint

Page size for each request, from 1 to 100. The server defaults to 50.

cursorstring

Starts the walk after this cursor instead of the first page.

apiKeystring

Overrides the client's API key for every page of this walk.

Döndürür

A Generator that yields one suggestion array per step.

Örnek

use OpenEmail\Constants\KnowledgeSuggestionKinds; foreach ($client->knowledge->iterateSuggestions(kind: KnowledgeSuggestionKinds::LEARNED) as $suggestion) {    echo $suggestion['scope'] === '' ? 'whole workspace' : $suggestion['scope'], ' ', $suggestion['title'], PHP_EOL;}

Notlar

  • The generator is lazy, so an abandoned loop costs only the pages you consumed.

Şurada da var

API
GET /knowledge/suggestions
TypeScript
knowledge.iterateSuggestions()
Python
knowledge.iterate_suggestions()
Ruby
knowledge.iterate_suggestions

knowledge->acceptSuggestion

Save a knowledge suggestion as a note

Kapsamlarknowledge:write
İmza
acceptSuggestion(string $id, ?array $body = null, ?string $apiKey = null): array

Saves a pending suggestion or question as a note, marks it accepted and returns both: the suggestion, its sourceId naming the new note, and the note itself in item. Any field you send takes the place of the suggested one, so you can tidy the title, rewrite the text, move it to another level or pin it on the way in. The note keeps the conversation the suggestion came from in threadId.

A question needs its answer in body, and its title stays the question unless you send one. Answering a question this way is how it becomes a note the AI uses from then on.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

Parametreler

idstringZorunlu

The id of the suggestion or question, kp_ and 24 hex characters, as knowledge->listSuggestions returns it.

titlestring

A title for the note, at most 200 characters. Left out, the suggested title or the question. The body is optional.

bodystring

The text of the note, up to 20,000 characters. Left out, the suggested note. A question needs it: the answer.

scopestring

The level for the note: an empty string for the whole workspace, @ and a domain, or one address. Left out, the suggested level.

pinnedbool

Puts the note into every prompt at its level. Left out, false.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with object set to knowledge_suggestion_accepted, suggestion, now accepted, and item, the new note with the fields knowledge->list returns.

Örnek

$accepted = $client->knowledge->acceptSuggestion('kp_3f9a1c7e5b2d8046a1c3e5f7', [    'body' => 'Orders over 50 euros ship free within the EU.',]); echo $accepted['item']['id'], ' ', $accepted['item']['status'], PHP_EOL;

Notlar

Şurada da var

API
POST /knowledge/suggestions/{id}/accept
TypeScript
knowledge.acceptSuggestion()
Python
knowledge.accept_suggestion()
Ruby
knowledge.accept_suggestion
CLI
openemail knowledge accept-suggestion

knowledge->dismissSuggestion

Dismiss a knowledge suggestion or question

Kapsamlarknowledge:write
İmza
dismissSuggestion(string $id, ?string $apiKey = null): array

Marks a pending suggestion or question dismissed and returns it. It leaves the pending list, the same fact or question is not suggested again, and nothing is added to the knowledge base.

Dismissing needs the reach to add a note at the level of the suggestion: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address.

Parametreler

idstringZorunlu

The id of the suggestion or question, kp_ and 24 hex characters, as knowledge->listSuggestions returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the suggestion, with status set to dismissed and decidedAt set.

Örnek

$dismissed = $client->knowledge->dismissSuggestion('kp_3f9a1c7e5b2d8046a1c3e5f7'); echo $dismissed['status'], ' ', $dismissed['decidedAt'] ?? '', PHP_EOL;

Notlar

Şurada da var

API
POST /knowledge/suggestions/{id}/dismiss
TypeScript
knowledge.dismissSuggestion()
Python
knowledge.dismiss_suggestion()
Ruby
knowledge.dismiss_suggestion
CLI
openemail knowledge dismiss-suggestion

knowledge->listFlags

List the open duplicate and conflict flags

Kapsamlarknowledge:read
İmza
listFlags(?string $itemId = null, ?int $limit = null, ?string $apiKey = null): array

Returns the open warnings about pairs of knowledge items as one list, newest first. Each item is compared with the closest items at every level when it is indexed, and again whenever it changes. duplicate means the two items say nearly the same thing. conflict means the AI found that two closely related items disagree on a fact, such as a price or a deadline, and detail says how in one sentence. The AI looks for conflicts while the workspace setting knowledgeLearning is on, at most 200 times a day.

Change or delete one of the two items to settle a flag: a changed item is compared again once it is indexed, and the flags of a deleted item go with it. When the two are fine as they are, dismiss the flag with knowledge->dismissFlag. A flag shows only to a caller who can see both items.

Parametreler

itemIdstring

Keeps the flags that name this knowledge item, on either side.

limitint

How many flags, from 1 to 100. The server defaults to 50.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

A list of arrays, each with id, kind, status, sourceId, sourceTitle, otherSourceId, otherSourceTitle, detail, score and createdAt. score is how close in meaning the two items are, from 0 to 1.

Örnek

$flags = $client->knowledge->listFlags(); foreach ($flags as $flag) {    echo $flag['kind'], ': ', $flag['sourceTitle'], ' and ', $flag['otherSourceTitle'], PHP_EOL;}

Notlar

  • Needs knowledge:read. Every item also carries flags, the number of open flags that name it, so knowledge->list shows which items to look at.

  • Only open flags are listed. A dismissed flag stays dismissed, and the same two items are not flagged for the same reason again.

Şurada da var

API
GET /knowledge/flags
TypeScript
knowledge.listFlags()
Python
knowledge.list_flags()
Ruby
knowledge.list_flags
CLI
openemail knowledge list-flags

knowledge->dismissFlag

Dismiss a duplicate or conflict flag

Kapsamlarknowledge:write
İmza
dismissFlag(string $id, ?string $apiKey = null): array

Marks a flag dismissed when the two items are fine as they are, and returns it. The same two items are not flagged for the same reason again. To settle a real duplicate or conflict instead, change or delete one of the items.

Dismissing needs the reach to change items at the levels of both items: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address.

Parametreler

idstringZorunlu

The id of the flag, kf_ and 24 hex characters, as knowledge->listFlags returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the flag, with status set to dismissed.

Örnek

$flag = $client->knowledge->dismissFlag('kf_7b3d9e1f5a2c8046b1d3e5f7'); echo $flag['status'], PHP_EOL;

Notlar

  • Needs knowledge:write. An unknown id, and a flag on an item the key cannot see, answer 404 knowledge_flag_not_found, and an item the key may not change is a 403 knowledge_scope_not_reached.

  • Dismissing a flag twice leaves it the same way, so the SDK retries it on network failure and retryable statuses.

Şurada da var

API
POST /knowledge/flags/{id}/dismiss
TypeScript
knowledge.dismissFlag()
Python
knowledge.dismiss_flag()
Ruby
knowledge.dismiss_flag
CLI
openemail knowledge dismiss-flag

knowledge->listConnectors

List the knowledge connectors

Kapsamlarknowledge:read
İmza
listConnectors(?string $apiKey = null): array

Returns every connector at a level the caller can see as one list, newest first. A connector keeps many web pages from one source in the knowledge base, each page as a link item at the connector's level: a site it crawls, a sitemap, an RSS or Atom feed, or a Zendesk help center. Each one says how many items it keeps, its status, when it last synced and when it syncs next.

Parametreler

apiKeystring

Overrides the client's API key for this call only.

Döndürür

A list of arrays, each with id, kind, scope, level, title, url, refreshDays, pageLimit, status, failure, items, lastSyncAt, nextSyncAt, createdAt and updatedAt.

Örnek

$connectors = $client->knowledge->listConnectors(); foreach ($connectors as $connector) {    echo $connector['kind'], ' ', $connector['url'], ' ', $connector['items'], ' ', $connector['status'], PHP_EOL;}

Notlar

  • Needs knowledge:read. A key or an app limited to particular addresses sees the connectors at the whole workspace, at its addresses and at their domains.

  • The items a connector keeps show in knowledge->list too, each with connectorId naming it.

Şurada da var

API
GET /knowledge/connectors
TypeScript
knowledge.listConnectors()
Python
knowledge.list_connectors()
Ruby
knowledge.list_connectors
CLI
openemail knowledge list-connectors

knowledge->addConnector

Keep the pages of a site, sitemap, feed or help center

Kapsamlarknowledge:write
İmza
addConnector(array $body, ?string $apiKey = null): array

Adds a connector at one level and returns it, queued. Its first sync starts within a minute, and every page it finds becomes a link item at the connector's level, read in the background like any other link.

site reads the page at url and follows its links to pages on the same host under the same path, leaving out what the site's robots.txt disallows. sitemap reads a sitemap, or a sitemap index and up to 5 of its sitemaps. feed reads an RSS or Atom feed. zendesk reads the published articles of a Zendesk help center from its address, such as https://example.zendesk.com.

It keeps at most pageLimit pages, 25 unless you say, and syncs again every refreshDays days, 7 unless you say: new pages are added, changed ones are read again and the items of pages that are gone are removed. A page already in the knowledge base as a link at the same level is left to that item. Its items count toward the plan allowance, and a sync stops adding pages once that is reached.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

Parametreler

kindstringZorunlu

What url is: site, sitemap, feed or zendesk, also in OpenEmail\Constants\KnowledgeConnectorKinds.

urlstringZorunlu

A public web address of at most 2,048 characters, kept as https: the page a site crawl starts from, the sitemap, the feed, or the address of the help center.

scopestring

The level: an empty string, or left out, for the whole workspace, @ and a domain such as @acme.com, or one address such as [email protected].

titlestring

A name for the connector, at most 200 characters. Left out, the host and the kind, such as acme.com (sitemap).

refreshDaysint

Sync again every 1, 7 or 30 days, also in OpenEmail\Constants\KnowledgeRefreshDayChoices. Left out, 7. Null syncs only when you call knowledge->syncConnector.

pageLimitint

The most pages to keep, from 1 to 200. Left out, 25.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the new connector, with status set to queued and items set to 0.

Örnek

use OpenEmail\Constants\KnowledgeConnectorKinds; $docs = $client->knowledge->addConnector([    'kind' => KnowledgeConnectorKinds::SITEMAP,    'url' => 'https://acme.com/sitemap.xml',    'scope' => '@acme.com',    'pageLimit' => 100,]); echo $docs['id'], ' ', $docs['status'], PHP_EOL;

Notlar

  • Needs knowledge:write.

  • An address that is not a public web address is a 422 invalid_knowledge_connector, and the same address at the same level a 409 knowledge_connector_exists. A refreshDays other than 1, 7, 30 or null is a 422 invalid_knowledge_refresh. A level that is not the workspace, one of its domains or one of its addresses is a 422 invalid_knowledge_scope, and a level outside what the key reaches is a 403 knowledge_scope_not_reached.

  • A source that cannot be read after several tries ends failed with a failure. A sync that stopped at the plan allowance ends ready with failure set to over_allowance, and one that found nothing ends ready with failure set to empty.

  • The SDK does not retry it. A second attempt after a lost response answers 409 knowledge_connector_exists, which means the first one worked.

Şurada da var

API
POST /knowledge/connectors
TypeScript
knowledge.addConnector()
Python
knowledge.add_connector()
Ruby
knowledge.add_connector
CLI
openemail knowledge add-connector

knowledge->getConnector

Read one knowledge connector

Kapsamlarknowledge:read
İmza
getConnector(string $id, ?string $apiKey = null): array

Returns one connector: its source, its level, how many items it keeps, its status, and when it last synced and syncs next. status is queued until a sync starts, syncing while it reads the source, ready once its pages are items, and failed with a failure when the source could not be read after several tries.

Parametreler

idstringZorunlu

The id of the connector, kc_ and 24 hex characters, as knowledge->listConnectors returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with the fields knowledge->listConnectors returns for each connector.

Örnek

$connector = $client->knowledge->getConnector('kc_5d2e8f1a3c7b9064e2a4c6f8'); echo $connector['status'], ' ', $connector['items'], ' ', $connector['nextSyncAt'] ?? 'not scheduled', PHP_EOL;

Notlar

Şurada da var

API
GET /knowledge/connectors/{id}
TypeScript
knowledge.getConnector()
Python
knowledge.get_connector()
Ruby
knowledge.get_connector
CLI
openemail knowledge get-connector

knowledge->updateConnector

Change a knowledge connector

Kapsamlarknowledge:write
İmza
updateConnector(string $id, array $patch, ?string $apiKey = null): array

Changes the title of a connector, its level, how often it syncs or the most pages it keeps, and returns it as it is now. Give at least one field. Moving it to another level moves its items with it, and they are indexed again there. A new refreshDays counts from the last sync, and a new pageLimit applies from the next sync.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole. Moving a connector needs that reach at both levels.

Parametreler

idstringZorunlu

The id of the connector, kc_ and 24 hex characters, as knowledge->listConnectors returns it.

titlestring

A new name, at most 200 characters.

scopestring

The level to move it and its items to: an empty string for the whole workspace, @ and a domain, or one address.

refreshDaysint

Sync every 1, 7 or 30 days, also in OpenEmail\Constants\KnowledgeRefreshDayChoices. Null syncs only when you call knowledge->syncConnector.

pageLimitint

The most pages to keep, from 1 to 200.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the connector as it is now.

Örnek

use OpenEmail\Constants\KnowledgeRefreshDayChoices; $connector = $client->knowledge->updateConnector('kc_5d2e8f1a3c7b9064e2a4c6f8', [    'refreshDays' => KnowledgeRefreshDayChoices::DAY,    'pageLimit' => 150,]); echo $connector['nextSyncAt'] ?? 'not scheduled', PHP_EOL;

Notlar

  • Needs knowledge:write. An empty patch is a 422 invalid_parameter, and a refreshDays other than 1, 7, 30 or null a 422 invalid_knowledge_refresh. Moving it to a level that already has a connector for the same address is a 409 knowledge_connector_exists.

  • Retried automatically on network failure and retryable statuses, since the same patch applied twice leaves the same connector.

Şurada da var

API
PATCH /knowledge/connectors/{id}
TypeScript
knowledge.updateConnector()
Python
knowledge.update_connector()
Ruby
knowledge.update_connector
CLI
openemail knowledge update-connector

knowledge->deleteConnector

Delete a knowledge connector and its items

Kapsamlarknowledge:write
İmza
deleteConnector(string $id, ?string $apiKey = null): array

Removes a connector with every item it added to the knowledge base, and the AI stops using them at once. There is no undo. Links you added yourself stay, even when the connector found the same pages.

Parametreler

idstringZorunlu

The id of the connector, kc_ and 24 hex characters, as knowledge->listConnectors returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with object set to knowledge_connector, id and deleted set to true.

Örnek

$removed = $client->knowledge->deleteConnector('kc_5d2e8f1a3c7b9064e2a4c6f8'); echo $removed['id'], ' ', $removed['deleted'] ? 'deleted' : 'kept', PHP_EOL;

Notlar

  • Needs knowledge:write, and reach over the level of the connector. An unknown id is a 404 knowledge_connector_not_found.

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

Şurada da var

API
DELETE /knowledge/connectors/{id}
TypeScript
knowledge.deleteConnector()
Python
knowledge.delete_connector()
Ruby
knowledge.delete_connector
CLI
openemail knowledge delete-connector

knowledge->syncConnector

Sync a knowledge connector now

Kapsamlarknowledge:write
İmza
syncConnector(string $id, ?string $apiKey = null): array

Queues a sync that starts within a minute, whatever the schedule says, clears any failure and returns the connector, back at queued. Use it after the source changed, or to try again after a failure. Like a scheduled sync, it adds new pages, reads changed ones again and removes the items of pages that are gone.

Parametreler

idstringZorunlu

The id of the connector, kc_ and 24 hex characters, as knowledge->listConnectors returns it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array for the connector, queued to sync.

Örnek

$connector = $client->knowledge->syncConnector('kc_5d2e8f1a3c7b9064e2a4c6f8'); echo $connector['status'], PHP_EOL;

Notlar

  • Needs knowledge:write, and reach over the level of the connector. An unknown id is a 404 knowledge_connector_not_found.

  • Queuing a sync twice leaves it the same way, so the SDK retries it on network failure and retryable statuses.

Şurada da var

API
POST /knowledge/connectors/{id}/sync
TypeScript
knowledge.syncConnector()
Python
knowledge.sync_connector()
Ruby
knowledge.sync_connector
CLI
openemail knowledge sync-connector

knowledge->draftFromThread

Draft a knowledge note from a conversation

Kapsamlarknowledge:writethreads:read
İmza
draftFromThread(array $body, ?string $apiKey = null): array

The AI reads a conversation and drafts one note of the facts in it that the team will need again, leaving out personal details and what matters only to that conversation. Nothing is saved: the draft comes back with a title, a body in Markdown and a scope it suggests, and you keep it, changed as you like, with knowledge->createNote and the same threadId.

scope suggests the domain the conversation arrived at when the caller may add items there, otherwise the whole workspace or the address itself. Each draft counts as one AI action.

Parametreler

threadIdstringZorunlu

The conversation, by the id threads->list gives it.

apiKeystring

Overrides the client's API key for this call only.

Döndürür

An array with object set to knowledge_draft, title, body, scope and threadId.

Örnek

$draft = $client->knowledge->draftFromThread(['threadId' => 'CAHk7pQ2x9LmZ4-mail.example.com']); $note = $client->knowledge->createNote([    'scope' => $draft['scope'],    'title' => $draft['title'],    'body' => $draft['body'],    'threadId' => $draft['threadId'],]); echo $note['id'], ' ', $note['threadId'] ?? '', PHP_EOL;

Notlar

Şurada da var

API
POST /knowledge/drafts
TypeScript
knowledge.draftFromThread()
Python
knowledge.draft_from_thread()
Ruby
knowledge.draft_from_thread
CLI
openemail knowledge draft-from-thread