---
title: "Collections.GetOrCreate"
description: "Get or create a collection by its name. If the collection does not exist, it will be created."
image: "https://tilebox.com/images/tilebox-docs-social-preview.png"
---

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

# Collections.GetOrCreate

import { Fragment } from "astro/jsx-runtime";

import ApiReference from "@docs/components/ApiReference.astro";

import ParamField from "@docs/components/ParamField.astro";

```go
func (collectionClient) GetOrCreate(
    ctx context.Context,
    datasetID uuid.UUID,
    name string,
) (*datasets.Collection, error)
```

Get or create a collection by its name. If the collection does not exist, it will be created.

## Parameters

**datasetID**

type: uuid.UUID

The id of the dataset
**name**

type: string

The name of the collection

## Returns

A collection object.

<h2 id="request-example">Usage example</h2>

```go
collection, err := client.Collections.GetOrCreate(ctx,
    datasetID,
    "My-collection",
)
```

Source: https://tilebox.com/docs/api-reference/go/datasets/Collections.GetOrCreate/index.mdx
