> For the complete documentation index, see [llms.txt](https://docs.drivequant.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.drivequant.com/trip-analysis/ios/custom-metadata.md).

# Custom metadata

{% hint style="warning" %}
Metadata is persisted, so if you want to send it only for one trip, you need to remove it at the end of the trip, on the [`sdkStateChanged(state: State)`](/trip-analysis/ios/triplistener.md)callback, by checking if `state` is `inactive`.
{% endhint %}

## Set metadata

You can add additional metadata to your trip by calling the following method:

```swift
let metadata: [String: String] = [
    "key": "value"
]
DriveKitTripAnalysis.shared.setTripMetadata(metadata)
```

The metadata must be represented as a key/value object where the key and value have a String type.

The metadata can be set any time before the end of a trip.

If metadata is sent, it will also be added to the push data request in the metaData field.

## Get metadata

It is possible to get a copy of configured metadata thanks to the following method on DriveKitTripAnalysis:

```swift
DriveKitTripAnalysis.shared.getTripMetadata()
```

{% hint style="info" %}
Note: Any modification on the returned object has no effect on the metadata sent with a trip.
{% endhint %}

## Update metadata

To update a value in metadata, call the following method:

```swift
DriveKitTripAnalysis.shared.updateTripMetadata(key: String, value: String?)
```

## Delete a specific metadata

To delete a specific value in metadata, call the following method:

```swift
DriveKitTripAnalysis.shared.deleteTripMetadata(key: String)
```

## Delete all metadata

To delete all values in metadata, call this method:

```swift
DriveKitTripAnalysis.shared.deleteTripMetadata()
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.drivequant.com/trip-analysis/ios/custom-metadata.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
