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

# Datasets.CreateOrUpdate

```go theme={"system"}
func (datasetClient) CreateOrUpdate(
    ctx context.Context,
    kind datasets.DatasetKind,
    codeName string,
    name string,
    fields []datasets.Field,
    options ...datasets.DatasetOption,
) (*datasets.Dataset, error)
```

Create a dataset or update an existing dataset if a dataset with the given `codeName` already exists.

If the dataset already exists, Tilebox applies the same schema update rules as a direct update. New fields can be added to non-empty datasets. Breaking schema changes are only allowed for empty datasets.

## Parameters

<ParamField path="kind" type="datasets.DatasetKind" required>
  The dataset kind.
</ParamField>

<ParamField path="codeName" type="string" required>
  The stable code identifier for the dataset.
</ParamField>

<ParamField path="name" type="string" required>
  The display name of the dataset.
</ParamField>

<ParamField path="fields" type="[]datasets.Field" required>
  The custom fields in the dataset schema.
</ParamField>

<ParamField path="options" type="[]datasets.DatasetOption">
  Options for dataset metadata.
</ParamField>

## Options

<ParamField path="datasets.WithSummary(summary string)">
  Set a short dataset summary.
</ParamField>

<ParamField path="datasets.WithDescription(description string)">
  Set the dataset's markdown description.
</ParamField>

## Dataset kinds

<ParamField path="KindTemporal" type="datasets.DatasetKind">
  A dataset that contains timestamp, ID, and ingestion time fields.
</ParamField>

<ParamField path="KindSpatiotemporal" type="datasets.DatasetKind">
  A dataset that contains timestamp, ID, ingestion time, and geometry fields.
</ParamField>

## Field types

<ParamField path="field.String(name string)" type="Field">
  A string field
</ParamField>

<ParamField path="field.Bytes(name string)" type="Field">
  A bytes field
</ParamField>

<ParamField path="field.Bool(name string)" type="Field">
  A boolean field
</ParamField>

<ParamField path="field.Int64(name string)" type="Field">
  A 64-bit signed integer field
</ParamField>

<ParamField path="field.Uint64(name string)" type="Field">
  A 64-bit unsigned integer field
</ParamField>

<ParamField path="field.Float64(name string)" type="Field">
  A 64-bit floating-point number field
</ParamField>

<ParamField path="field.Duration(name string)" type="Field">
  A duration field
</ParamField>

<ParamField path="field.Timestamp(name string)" type="Field">
  A timestamp field
</ParamField>

<ParamField path="field.UUID(name string)" type="Field">
  A UUID field
</ParamField>

<ParamField path="field.Geometry(name string)" type="Field">
  A geometry field
</ParamField>

## Field options

<ParamField path="Repeated()">
  Indicate that the field is an array
</ParamField>

<ParamField path="Description(description string)">
  Set the description of the field to provide more context and details about the data
</ParamField>

<ParamField path="ExampleValue(exampleValue string)">
  Set the example value of the field for documentation purposes
</ParamField>

## Returns

The created or updated dataset object.

<RequestExample>
  ```go Go theme={"system"}
  dataset, err := client.Datasets.CreateOrUpdate(ctx,
      datasets.KindSpatiotemporal,
      "my_catalog",
      "My catalog",
      []datasets.Field{
          field.String("field1"),
          field.Int64("field2").Repeated(),
          field.Geometry("field3").Description("Field 3").ExampleValue("Value 3"),
      },
      datasets.WithSummary("Scenes prepared for analysis"),
  )
  ```
</RequestExample>
