# UUID

The UUID type represents a UUID v4 or v7 value with CBOR tag 37 encoding for SurrealDB.

The `UUID` struct wraps the `github.com/gofrs/uuid` package and handles CBOR encoding with tag 37 as specified by SurrealDB. It supports both UUID v4 and v7 values.

**Package:** `github.com/surrealdb/surrealdb.go/pkg/models`

**Source:** [pkg/models/uuid.go](https://github.com/surrealdb/surrealdb.go/blob/main/pkg/models/uuid.go)

---

## Definition

```go
type UUID struct {
    uuid.UUID
}
```

`UUID` embeds `github.com/gofrs/uuid.UUID`, so all methods from that package are available directly.

---

## Related types

### `UUIDString` {#uuidstring}

A string type for UUID values that prefer string representation. Encoded with CBOR tag 9.

```go
type UUIDString string
```

---

## CBOR encoding

`UUID` is encoded as CBOR tag 37 containing the 16-byte binary representation. `UUIDString` is encoded as CBOR tag 9 containing the string representation.

---

## Usage

`UUID` is returned by live query functions and session/transaction creation. You typically receive it from the SDK rather than constructing it manually.

```go
liveID, err := surrealdb.Live(ctx, db, models.Table("persons"), false)
fmt.Println(liveID.String())
```

---

## See also

- [Live queries](/docs/reference/golang/concepts/live-queries.md) for live query UUIDs
- [Session](/docs/reference/golang/api/core/session.md#id) for session UUIDs
- [Transaction](/docs/reference/golang/api/core/transaction.md#id) for transaction UUIDs
- [Value types](/docs/reference/golang/concepts/value-types.md) for the full type mapping
- [SurrealQL UUID type](/docs/reference/query-language/language-primitives/data-types/uuids.md) for the underlying data model
