> ## Documentation Index
> Fetch the complete documentation index at: https://developers.redo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# knowledgeCsvImport

> Import knowledge articles from CSV, as the Knowledge page's import does: columns Title (or Name) and Content, and optionally Status (Active, Draft or Disabled; Draft when blank) and Effective start and Effective end. Each valid row becomes an article at once, not staged. Returns one result per data row: OK with the article, SKIPPED with DUPLICATE_TITLE and the store's article for a title the store already has, or FAILED with the reason for a row that can't be read. Sending the same file again creates nothing new and names the same articles, so there is no idempotencyKey. At most 500 data rows and 1,000,000 characters; BAD_USER_INPUT for a larger file, one with no data rows, or one missing Title or Content, and nothing is created. Pass the file as `url` (a public https URL Redo fetches) or, for a small one, its text as `csv`. Two imports of one file at the same time still create each title once. It goes live at once, so it needs `commerce_agent_knowledge_publish`; `commerce_agent_knowledge_write` alone is refused with INSUFFICIENT_SCOPE.

**Required scopes:** [`commerce_agent_knowledge_publish`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-commerce_agent_knowledge_publish)

## Arguments

**csv** `String`

The CSV file's text, header row first. Pass this or `url`, not both.

**url** `String`

A public https URL of the CSV file, which Redo fetches. Pass this or `csv`, not both.

## Returns

**knowledgeCsvImport** `[KnowledgeCsvImportResult!](/docs/api-reference/v3/reference/commerce-agent/knowledge-csv-import-result)` *required*

What a knowledge CSV import did with each data row. It runs while the request waits, so the result is final.

**fields**

**counts** `[BulkCounts!](/docs/api-reference/v3/reference/common/bulk-counts)` *required*

How many items ended each way.

**fields**

**failed** `Int!` *required*

The items that couldn't be changed.

**ok** `Int!` *required*

The items the action changed.

**skipped** `Int!` *required*

The items it didn't apply to.

**total** `Int!` *required*

The items given.

**results** `[\[KnowledgeCsvImportRow!\]!](/docs/api-reference/v3/reference/commerce-agent/knowledge-csv-import-row)` *required*

One per data row, in file order; at most 500.

**fields**

**article** `[KnowledgeArticle](/docs/api-reference/v3/reference/commerce-agent/knowledge-article)`

The article the row created, or for DUPLICATE\_TITLE the store's article with that title. Null for a row that couldn't be read.

**fields**

**changes** `[KnowledgeArticleChangeConnection!](/docs/api-reference/v3/pagination)` *required*

Every change to this article and who made it, newest first, including staged drafts and removals.

**Requires:** [`commerce_agent_knowledge_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-commerce_agent_knowledge_read)

**fields**

**Arguments**

**after** `String`

Forward pagination cursor — returns changes after it.

**before** `String`

Backward pagination cursor — returns changes before it.

**first** `Int`

Forward pagination: returns the first N changes (max 100, default 25). Use with `after`; mutually exclusive with `last`/`before`.

**last** `Int`

Backward pagination: returns the last N changes (max 100, default 25). Use with `before`; mutually exclusive with `first`/`after`.

**content** `String!` *required*

The live article body as authored.

**createdAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the article was created.

**draft** `[KnowledgeArticleDraft](/docs/api-reference/v3/reference/commerce-agent/knowledge-article-draft)`

Changes staged by the API and not yet published. Null when nothing is staged. Reading it needs a token with `commerce_agent_knowledge_read`.

**Requires:** [`commerce_agent_knowledge_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-commerce_agent_knowledge_read)

**effectiveEndAt** `[DateTime](/docs/api-reference/v3/reference/common/date-time)`

When the live article stops being retrievable. Null means no end.

**effectiveStartAt** `[DateTime](/docs/api-reference/v3/reference/common/date-time)`

When the live article becomes retrievable, if `status` is ACTIVE. Null means immediately.

**id** `ID!` *required*

The id of this knowledge article.

**origin** `[KnowledgeArticleOrigin!](/docs/api-reference/v3/reference/commerce-agent/knowledge-article-origin)` *required*

How this article was created. Immutable after create.

**productFamilies** `[ProductFamilyConnection!](/docs/api-reference/v3/pagination)` *required*

Product families this article cites.

**Requires:** [`products_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-products_read)

**fields**

**Arguments**

**after** `String`

Forward pagination cursor — returns items after it. Pass an `edges[].cursor` or `pageInfo.endCursor` from a previous page.

**before** `String`

Backward pagination cursor — returns items before it. Pass an `edges[].cursor` or `pageInfo.startCursor` from a previous page.

**first** `Int`

Forward pagination: returns the first N items (max 100, default 25). Use with `after`; mutually exclusive with `last`/`before`.

**last** `Int`

Backward pagination: returns the last N items (max 100, default 25). Use with `before`; mutually exclusive with `first`/`after`.

**referencedArticles** `[KnowledgeArticleConnection!](/docs/api-reference/v3/pagination)` *required*

Other knowledge articles this article cites.

**Requires:** [`commerce_agent_knowledge_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-commerce_agent_knowledge_read)

**fields**

**Arguments**

**after** `String`

Forward pagination cursor — returns items after it. Pass an `edges[].cursor` or `pageInfo.endCursor` from a previous page.

**before** `String`

Backward pagination cursor — returns items before it. Pass an `edges[].cursor` or `pageInfo.startCursor` from a previous page.

**first** `Int`

Forward pagination: returns the first N items (max 100, default 25). Use with `after`; mutually exclusive with `last`/`before`.

**last** `Int`

Backward pagination: returns the last N items (max 100, default 25). Use with `before`; mutually exclusive with `first`/`after`.

**status** `[KnowledgeArticleStatus!](/docs/api-reference/v3/reference/commerce-agent/knowledge-article-status)` *required*

Whether Commerce Agent may retrieve this live article. Combine with the effective window.

**title** `String!` *required*

The live merchant-facing title of the article.

**updatedAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the live article body was last edited.

**usageCount** `Int!` *required*

How many messages Commerce Agent used this article in. Unsent draft replies don't count. This is the number the merchant app's Knowledge page shows as Uses.

**whenToUse** `String!` *required*

The text Commerce Agent matches a shopper's question against to pick this article. It is generated from the live title and content, so it is read-only. A new article starts with its title. After an edit, the previous text stays until it is regenerated.

**code** `String`

Why the item was skipped or failed: DUPLICATE\_TITLE, the store already has an article with the row's title (`article` is that article); MISSING\_TITLE, MISSING\_CONTENT, INVALID\_STATUS, INVALID\_EFFECTIVE\_START, INVALID\_EFFECTIVE\_END, EFFECTIVE\_END\_BEFORE\_START, the row couldn't be read, as `message` says. Null when it is OK.

**message** `String`

The same, in words. Null when it is OK.

**row** `Int!` *required*

The row's position in the file, counting the header as row 1. A quoted line break inside a cell doesn't start a new row.

**status** `[BulkItemStatus!](/docs/api-reference/v3/reference/common/bulk-item-status)` *required*

What the action did with the item.

## Errors

Besides the [errors any request can return](https://developers.redo.com/docs/api-reference/v3/errors.md), this operation fails with these codes in `extensions.code`.

| Code | HTTP status | Meaning | Retry |
| - | - | - | - |
| `BAD_USER_INPUT` | `400` | An argument is invalid, or names something the store doesn't have. The message says which. Nothing was written. | Fix the input the message names, then send it again. |
| `INTERNAL_SERVER_ERROR` | `500` | Something failed on Redo's side. The change may or may not have been made. | Read the record to see whether the change was made before sending it again. A send with an idempotencyKey is safe to retry with the same key. |

## Example

```graphql theme={null}
mutation {
  knowledgeCsvImport(csv: "...", url: "...")
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.