# Datapoints.Ingest

```go
func (datapointClient) Ingest(
    ctx context.Context,
    collectionID uuid.UUID,
    datapoints any,
    allowExisting bool,
) (*datasets.IngestResponse, error)
```

Ingest data points into a collection.

## Parameters

**collectionID**

`uuid.UUID`

The id of the collection

**datapoints**

`*[]proto.Message`

The datapoints to ingest

**allowExisting**

`bool`

Datapoint fields are used to generate a deterministic unique `UUID` for each
datapoint in a collection. Duplicate data points result in the same ID being generated.
If `allowExisting` is `true`, `ingest` will skip those datapoints, since they already exist.
If `allowExisting` is `false`, `ingest` will raise an error if any of the generated datapoint IDs already exist.

## Returns

An `IngestResponse` with `NumCreated`, `NumExisting`, and `DatapointIDs`. `DatapointIDs` includes the IDs of ingested datapoints and, when `allowExisting` is `true`, the IDs of datapoints that already existed.

```go title="Go"
datapoints := []*v1.Modis{
  v1.Modis_builder{
    Time:        timestamppb.New(time.Now()),
    GranuleName: proto.String("Granule 1"),
  }.Build(),
  v1.Modis_builder{
    Time:        timestamppb.New(time.Now().Add(-5 * time.Hour)),
    GranuleName: proto.String("Past Granule 2"),
  }.Build(),
}

ingestResponse, err := client.Datapoints.Ingest(ctx,
    collectionID,
    &datapoints,
    false,
)
```

## Errors

**ArgumentError**

`found existing datapoints with same id`

If `allowExisting` is `false` and any datapoints already exist.
