> This is the Markdown version of the page. For the complete Lattice Developers documentation index, fetch https://developer.anduril.com/llms.txt. Append .md to any page URL for its clean Markdown.

# Synchronize clocks

> Keep your client clock in sync with Lattice so that published entities are accepted.

Lattice checks the timestamps on every entity you publish against its own clock.
If the clock on your client drifts, Lattice can reject your entities or ignore your updates.
Often there is no error.
A common symptom is an integration that works from one computer but not from another.

## How Lattice checks time

Lattice applies three rules to each published entity:

* [`expiry_time`](/reference/rest/entities/publish-entity#request.body.expiryTime) must be later than the current Lattice time.
* [`provenance.source_update_time`](/reference/rest/entities/publish-entity#request.body.provenance.sourceUpdateTime)
  must be no more than 10 minutes ahead of the current Lattice time.
* `PublishEntity` applies an update to an existing entity only if its `source_update_time` is later than the stored value.

Most integrations set both timestamps from the local clock.
For example, an integration might set `expiry_time` to 10 seconds after the current time.
If that client's clock is more than 10 seconds behind, every publish fails.

## What happens when clocks drift

The following results come from tests against Lattice with a client clock set ahead or behind.

| Client clock                                                           | REST `PublishEntity`                                 | gRPC `PublishEntity`                 | gRPC `PublishEntities`               |
| ---------------------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------ | ------------------------------------ |
| Behind by more than your expiry offset                                 | `400 VALIDATION_ERROR`                               | `INVALID_ARGUMENT`                   | Returns success. Drops the entity.   |
| Ahead by more than 10 minutes                                          | `400 VALIDATION_ERROR`                               | `INVALID_ARGUMENT`                   | Returns success. Drops the entity.   |
| Ahead by less than 10 minutes                                          | Accepted. The entity stays live longer than you set. | Same as REST                         | Same as REST                         |
| Behind, while updating an entity that has a later `source_update_time` | Returns success. Ignores the update.                 | Returns success. Ignores the update. | Returns success. Applies the update. |

The error message names the field that failed and includes the current Lattice time:

* `expiry_time <time> must be after the present time <time>`
* `provenance.source_update_time must be a valid timestamp or no greater than 10m0s later than <time>`

REST responses use `camelCase` field names, such as `expiryTime`.

A client clock that runs ahead also affects other publishers.
After it publishes an entity, `PublishEntity` ignores updates to that entity from clients with correct clocks.
This lasts until real time catches up with the future `source_update_time`.

> **Warning**
>
> `PublishEntities` doesn't report rejected entities.
> The stream closes with success even when Lattice drops every entity.
> To see validation errors while you debug, publish with `PublishEntity` instead.

## Check your clock offset

Lattice responses include a `Date` header with the current Lattice time, to the second.
Compare it with your local clock:

```bash
curl -sk -o /dev/null -D - https://<lattice-endpoint>/api/v1/entities/<any-entity-id> | grep -i '^date:'
date -u
```

The request doesn't need to succeed.
Error responses, such as `401` or `404`, still include the `Date` header.
If the two times differ by more than a few seconds, fix the client clock before you debug anything else.

## Keep clocks in sync

* Run a time synchronization service, such as an NTP client, on every computer that publishes entities.
* On a disconnected network, use a time source on the same network as Lattice.
* Log the error message from every failed publish.
  The message includes the Lattice time, which shows the offset.
* When your integration starts, compare the local time with the `Date` header and warn if they differ.

## What's next

* Learn how to [create an asset](/guides/entities/create-an-asset) and set its timestamps.
* Review [Retry connections](/guides/best-practices/retry-connections) to decide which errors to retry.