---
title: Insert Vectors
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[Vectorize](https://developers.cloudflare.com/api/go/resources/vectorize)

[Indexes](https://developers.cloudflare.com/api/go/resources/vectorize/subresources/indexes)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Insert Vectors

client.Vectorize.Indexes.Insert(ctx, indexName, params) (\*[IndexInsertResponse](<https://developers.cloudflare.com/api/go/resources/vectorize#(resource)%20vectorize.indexes%20%3E%20(model)%20IndexInsertResponse%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/vectorize/v2/indexes/{index\_name}/insert

Inserts vectors into the specified index and returns a mutation id corresponding to the vectors enqueued for insertion.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Vectorize Write`

##### ParametersExpand Collapse

indexName string

[Link to this property](<#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20index_name%20%3E%20(schema)>)

<details>

<summary>

params IndexInsertParams

</summary>

AccountID param.Field\[string]

Path param: Identifier

maxLength32

<a href="#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

Body param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/vectorize/subresources/indexes/methods/insert#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)">Reader</a>]

Body param: ndjson file containing vectors to insert.

<a href="#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20body">Link to this property</a>

<details>

<summary>

UnparsableBehavior param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/vectorize/subresources/indexes/methods/insert#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20unparsable-behavior%20%3E%20(schema)">IndexInsertParamsUnparsableBehavior</a>]Optional

Query param: Behavior for ndjson parse failures.

</summary>

const IndexInsertParamsUnparsableBehaviorError <a href="https://developers.cloudflare.com/api/go/resources/vectorize/subresources/indexes/methods/insert#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20unparsable-behavior%20%3E%20(schema)">IndexInsertParamsUnparsableBehavior</a> = "error"

<a href="#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20unparsable-behavior%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const IndexInsertParamsUnparsableBehaviorDiscard <a href="https://developers.cloudflare.com/api/go/resources/vectorize/subresources/indexes/methods/insert#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20unparsable-behavior%20%3E%20(schema)">IndexInsertParamsUnparsableBehavior</a> = "discard"

<a href="#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20unparsable-behavior%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default%20%3E%20(param)%20unparsable-behavior">Link to this property</a>

</details>

[Link to this property](<#(resource)%20vectorize.indexes%20%3E%20(method)%20insert%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type IndexInsertResponse struct{…}

</summary>

MutationID stringOptional

The unique identifier for the async mutation operation containing the changeset.

maxLength36

<a href="#(resource)%20vectorize.indexes%20%3E%20(model)%20IndexInsertResponse%20%3E%20(schema)%20%3E%20(property)%20mutationId">Link to this property</a>

</details>

[Link to this property](<#(resource)%20vectorize.indexes%20%3E%20(model)%20IndexInsertResponse%20%3E%20(schema)>)

### Insert Vectors

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "bytes"
  "context"
  "fmt"
  "io"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/vectorize"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.Vectorize.Indexes.Insert(
    context.TODO(),
    "example-index",
    vectorize.IndexInsertParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      Body: io.Reader(bytes.NewBuffer([]byte("Example data"))),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.MutationID)
}
```

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "mutationId": "0000aaaa-11bb-22cc-33dd-444444eeeeee"
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "mutationId": "0000aaaa-11bb-22cc-33dd-444444eeeeee"
  },
  "success": true
}
```