Skip to content
Start here

Create new job

client.AISearch.Namespaces.Instances.Jobs.New(ctx, name, id, params) (*NamespaceInstanceJobNewResponse, error)
POST/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/jobs

Creates a new indexing job for an AI Search instance.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

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

Example:X-Auth-Email: user@example.com

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

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
ParametersExpand Collapse
name string
id string

AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.

maxLength64
minLength1
params NamespaceInstanceJobNewParams
AccountID param.Field[string]

Path param

Description param.Field[string]Optional

Body param

maxLength255
ReturnsExpand Collapse
type NamespaceInstanceJobNewResponse struct{…}
ID string
Source NamespaceInstanceJobNewResponseSource
One of the following:
const NamespaceInstanceJobNewResponseSourceUser NamespaceInstanceJobNewResponseSource = "user"
const NamespaceInstanceJobNewResponseSourceSchedule NamespaceInstanceJobNewResponseSource = "schedule"
Description stringOptional
EndReason stringOptional
EndedAt stringOptional
LastSeenAt stringOptional
StartedAt stringOptional

Create new job

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/ai_search"
  "github.com/stainless-sdks/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  job, err := client.AISearch.Namespaces.Instances.Jobs.New(
    context.TODO(),
    "my-namespace",
    "my-ai-search",
    ai_search.NamespaceInstanceJobNewParams{
      AccountID: cloudflare.F("c3dc5f0b34a14ff8e1b3ec04895e1b22"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", job.ID)
}
{
  "result": {
    "id": "id",
    "source": "user",
    "description": "description",
    "end_reason": "end_reason",
    "ended_at": "ended_at",
    "last_seen_at": "last_seen_at",
    "started_at": "started_at"
  },
  "success": true
}
Returns Examples
{
  "result": {
    "id": "id",
    "source": "user",
    "description": "description",
    "end_reason": "end_reason",
    "ended_at": "ended_at",
    "last_seen_at": "last_seen_at",
    "started_at": "started_at"
  },
  "success": true
}