### Maven Dependency Installation
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Add this dependency to your pom.xml file for Maven projects.
```xml
com.andurillattice-sdk5.7.1
```
--------------------------------
### Gradle Dependency Installation
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Add this dependency to your build.gradle file for Gradle projects.
```groovy
dependencies {
implementation 'com.anduril:lattice-sdk:5.7.1'
}
```
--------------------------------
### client.oauth.getToken(request)
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Gets a new short-lived token using the specified client credentials.
```APIDOC
## client.oauth.getToken(request)
### Description
Gets a new short-lived token using the specified client credentials.
### Usage Example
```java
client.oauth().getToken(
GetTokenRequest
.builder()
.build()
);
```
```
--------------------------------
### Get OAuth Token in Lattice SDK Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Gets a new short-lived token using the specified client credentials.
```java
client.oauth().getToken(
GetTokenRequest
.builder()
.build()
);
```
--------------------------------
### client.tasks.streamManualControlFrames
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Establishes a server streaming connection that delivers manual control frames to agents using server-sent events (SSE). This endpoint streams manual control frames, for example, for joystick movements, for a specific task to the executing agent. The agent should open this stream before reporting STATUS_EXECUTING to ensure it is ready to receive control input when the operator begins sending frames. Each frame includes epoch and sequence metadata for handling concurrent control sessions and detecting stale or out-of-order frames. Heartbeat messages are sent periodically to maintain the connection. The stream terminates automatically when the task reaches a terminal state.
```APIDOC
## streamManualControlFrames
### Description
Establishes a server streaming connection that delivers manual control frames to agents
using server-sent events (SSE).
This endpoint streams manual control frames, for example, for joystick movements, for a specific task
to the executing agent. The agent should open this stream before reporting `STATUS_EXECUTING`
to ensure it is ready to receive control input when the operator begins sending frames.
Each frame includes epoch and sequence metadata for handling concurrent control sessions
and detecting stale or out-of-order frames. Heartbeat messages are sent periodically to
maintain the connection.
The stream terminates automatically when the task reaches a terminal state
(`STATUS_DONE_OK` or `STATUS_DONE_NOT_OK`).
### Method
POST (Implied by client usage)
### Endpoint
/tasks/{taskId}/streamManualControlFrames (Implied by client usage)
### Parameters
#### Path Parameters
- **taskId** (String) - Required - The ID of the manual control task to receive frames for.
#### Request Body
- **heartbeatIntervalMs** (Optional) - Optional - The time interval, in milliseconds, that determines the frequency at which to send heartbeat events. Defaults to 30000 (30 seconds).
```
--------------------------------
### Get Object Metadata in Lattice SDK Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Returns metadata for a specified object path, such as size, expiry time, or last updated timestamp.
```java
client.objects().getObjectMetadata(
"objectPath",
GetObjectMetadataRequest
.builder()
.build()
);
```
--------------------------------
### Long Poll Entity Events with Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Use this method to long poll for entity events. Provide a session token to continue an existing polling session or leave it empty to start a new one.
```java
client.entities().longPollEntityEvents(
EntityEventRequest
.builder()
.sessionToken("sessionToken")
.build()
);
```
--------------------------------
### Get Task
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Retrieves a specific Task by its ID. This method returns detailed information about a task including its current status, specification, relations, and other metadata. The response includes the complete Task object with all associated fields. By default, the method returns the latest definition version of the task.
```APIDOC
## GET /tasks/{taskId}
### Description
Retrieves a specific Task by its ID, with options to select a particular task version or view. This method returns detailed information about a task including its current status, specification, relations, and other metadata. The response includes the complete Task object with all associated fields. By default, the method returns the latest definition version of the task from the manager's perspective.
### Method
GET
### Endpoint
/tasks/{taskId}
### Parameters
#### Path Parameters
- **taskId** (String) - Required - ID of task to return
### Response
#### Success Response (200)
- **Task** (Task) - Detailed information about the task.
```
--------------------------------
### Client Initialization - Synchronous
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Demonstrates how to build a synchronous Lattice client using various authentication methods and configuration options.
```APIDOC
## `Lattice.builder()` — Build a synchronous client
The primary entry point. Supports bearer token auth, OAuth credentials, custom URL, timeout, retries, and custom headers.
```java
import com.anduril.Lattice;
import com.anduril.core.Environment;
import com.anduril.core.LogConfig;
import com.anduril.core.LogLevel;
// Option 1: Bearer token authentication with a custom server hostname
Lattice client = Lattice.builder()
.server("my-env.developer.anduril.com")
.token("my-access-token")
.timeout(120) // seconds; default is 60
.maxRetries(3) // default is 2
.addHeader("X-Request-Id", "req-001")
.logging(LogConfig.builder()
.level(LogLevel.DEBUG)
.silent(false)
.build())
.build();
// Option 2: OAuth client credentials (automatic token acquisition + refresh)
Lattice oauthClient = Lattice.builder()
.url("https://my-env.developer.anduril.com")
.credentials("my-client-id", "my-client-secret")
.build();
// Option 3: Named environment constant
Lattice defaultClient = Lattice.builder()
.environment(Environment.DEFAULT) // https://example.developer.anduril.com
.token("my-access-token")
.build();
```
```
--------------------------------
### Client Initialization - Asynchronous
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Shows how to build an asynchronous Lattice client, mirroring the synchronous client's configuration options.
```APIDOC
## `AsyncLattice.builder()` — Build an asynchronous client
Mirrors the synchronous `Lattice` client; all resource methods return `CompletableFuture`.
```java
import com.anduril.AsyncLattice;
AsyncLattice asyncClient = AsyncLattice.builder()
.url("https://my-env.developer.anduril.com")
.credentials("my-client-id", "my-client-secret")
.timeout(90)
.build();
// All resource accessors are the same as the sync client:
// asyncClient.entities(), asyncClient.tasks(), asyncClient.objects(), asyncClient.oauth()
```
```
--------------------------------
### Initialize Synchronous Lattice Client with Named Environment
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Build a synchronous Lattice client using a predefined environment constant. Requires a bearer token.
```java
// Option 3: Named environment constant
Lattice defaultClient = Lattice.builder()
.environment(Environment.DEFAULT) // https://example.developer.anduril.com
.token("my-access-token")
.build();
```
--------------------------------
### Basic Client Instantiation and Usage
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Instantiate the Lattice client with a server URL and use it to access entities.
```java
package com.example.usage;
import com.anduril.Lattice;
Lattice client = Lattice
.builder()
.server("YOUR_SERVER")
.build();
client.entities().longPollEntityEvents(...);
```
--------------------------------
### Entities API - Get Entity
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Retrieves a specific entity using its unique identifier.
```APIDOC
## `client.entities().getEntity(entityId, request)` — Retrieve a single entity
Fetches a specific entity by its unique ID.
```java
import com.anduril.resources.entities.requests.GetEntityRequest;
import com.anduril.types.Entity;
Entity entity = client.entities().getEntity(
"entity-uuid-1234",
GetEntityRequest.builder().build()
);
System.out.println("Entity: " + entity);
```
```
--------------------------------
### Using a Custom OkHttpClient
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Pass a pre-configured OkHttpClient instance to the SDK builder.
```java
import com.anduril.Lattice;
import okhttp3.OkHttpClient;
OkHttpClient customClient = ...;
Lattice client = Lattice
.builder()
.httpClient(customClient)
.build();
```
--------------------------------
### Get Entity by ID
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Retrieves an entity by its unique ID. Requires the entity's ID and an optional GetEntityRequest builder.
```java
client.entities().getEntity(
"entityId",
GetEntityRequest
.builder()
.build()
);
```
--------------------------------
### Client Instantiation with Default Environment
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Configure the client to use the default environment for API requests.
```java
import com.anduril.Lattice;
import com.anduril.core.Environment;
Lattice client = Lattice
.builder()
.environment(Environment.Default)
.build();
```
--------------------------------
### Initialize Asynchronous Lattice Client
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Build an asynchronous Lattice client. This client mirrors the synchronous client's API but returns CompletableFuture for all resource methods. Timeout can be configured.
```java
import com.anduril.AsyncLattice;
AsyncLattice asyncClient = AsyncLattice.builder()
.url("https://my-env.developer.anduril.com")
.credentials("my-client-id", "my-client-secret")
.timeout(90)
.build();
// All resource accessors are the same as the sync client:
// asyncClient.entities(), asyncClient.tasks(), asyncClient.objects(), asyncClient.oauth()
```
--------------------------------
### Listen as Agent with Java SDK
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Initiate a connection to listen for tasks as an agent. This method is part of the agent's interface for receiving task assignments and updates.
```java
client.tasks().listenAsAgent(
request
);
```
--------------------------------
### Get Task by ID - Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Retrieves a specific Task by its ID. Use this method to fetch detailed information about a task, including its status, specification, and relations. The latest definition version is returned by default.
```java
client.tasks().getTask(
"taskId",
GetTaskRequest
.builder()
.build()
);
```
--------------------------------
### Listen for Tasks as an Agent
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Establishes a server streaming connection to receive tasks. This method is suitable for agents that need to listen for tasks in real-time. The connection will block until a task is ready or a 5-minute timeout occurs, after which a new request must be initiated.
```java
client.tasks().listenAsAgent(
AgentListener
.builder()
.build()
);
```
--------------------------------
### longPollEntityEvents
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Long-polling endpoint that returns pre-existing and new entity events. Start a session with an empty `sessionToken`; reuse the returned token for subsequent polls. The server holds the connection for up to 5 minutes when no new data is available.
```APIDOC
## longPollEntityEvents
### Description
Long-polling endpoint that returns pre-existing and new entity events. Start a session with an empty `sessionToken`; reuse the returned token for subsequent polls. The server holds the connection for up to 5 minutes when no new data is available.
### Method
```java
client.entities().longPollEntityEvents(request, requestOptions)
```
### Parameters
#### Request Body
- **request** (EntityEventRequest) - Required - Contains the session token and batch size.
- **sessionToken** (string) - Optional - The token for the current session. Empty to start a new session.
- **batchSize** (integer) - Optional - The maximum number of events to return (1–2000, default 100).
#### Request Options
- **requestOptions** (RequestOptions) - Optional - Options for the request, such as timeout.
- **timeout** (integer) - Optional - The timeout for the request in seconds.
### Request Example
```java
import com.anduril.core.LatticeApiException;
import com.anduril.core.RequestOptions;
import com.anduril.resources.entities.requests.EntityEventRequest;
String sessionToken = ""; // empty to start a new session
while (true) {
try {
var response = client.entities().longPollEntityEvents(
EntityEventRequest.builder()
.sessionToken(sessionToken)
.batchSize(500) // 1–2000, default 100
.build(),
RequestOptions.builder()
.timeout(360) // exceed server's 5-min hold
.build()
);
sessionToken = response.sessionToken();
response.entityEvents().forEach(event ->
System.out.println("Event type=" + event.eventType() + " entity=" + event.entity()));
} catch (LatticeApiException e) {
System.err.println("Poll error: " + e.getMessage());
Thread.sleep(2000);
}
}
```
### Response
#### Success Response (200)
- **EntityEventResponse** (EntityEventResponse) - Contains entity events and a session token.
- **sessionToken** (string) - The token to use for the next poll.
- **entityEvents** (List) - A list of entity events.
```
--------------------------------
### client.tasks.createTask
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Creates a new Task in the system with the specified parameters. Sets the initial task state and establishes ownership.
```APIDOC
## createTask
### Description
Creates a new Task in the system with the specified parameters. This method initiates a new task with a unique ID (either provided or auto-generated), sets the initial task state to STATUS_CREATED, and establishes task ownership. The task can be assigned to a specific agent through the Relations field. Once created, a task enters the lifecycle workflow and can be tracked, updated, and managed through other Tasks API endpoints.
### Method
Not specified (likely POST)
### Endpoint
Not specified
### Parameters
#### Request Body
- **TaskCreation** (Object) - Required - Object containing parameters for task creation. Specific fields are not detailed in the source.
### Request Example
```java
client.tasks().createTask(
TaskCreation
.builder()
.build()
);
```
### Response
#### Success Response (200)
- **Task** (Object) - The created Task object, including its ID and status.
#### Response Example
{
"id": "task-abc",
"status": "STATUS_CREATED",
"relations": {
"assignedAgentId": "agent-xyz"
}
}
```
--------------------------------
### Initialize Synchronous Lattice Client with OAuth Credentials
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Build a synchronous Lattice client using OAuth client credentials for authentication, which handles automatic token acquisition and refresh.
```java
// Option 2: OAuth client credentials (automatic token acquisition + refresh)
Lattice oauthClient = Lattice.builder()
.url("https://my-env.developer.anduril.com")
.credentials("my-client-id", "my-client-secret")
.build();
```
--------------------------------
### Long-poll for entity events
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Long-polling endpoint that returns pre-existing and new entity events. Start a session with an empty sessionToken; reuse the returned token for subsequent polls. The server holds the connection for up to 5 minutes when no new data is available. Handle LatticeApiException for poll errors and use Thread.sleep for retries.
```java
import com.anduril.core.LatticeApiException;
import com.anduril.core.RequestOptions;
import com.anduril.resources.entities.requests.EntityEventRequest;
String sessionToken = ""; // empty to start a new session
while (true) {
try {
var response = client.entities().longPollEntityEvents(
EntityEventRequest.builder()
.sessionToken(sessionToken)
.batchSize(500) // 1–2000, default 100
.build(),
RequestOptions.builder()
.timeout(360) // exceed server's 5-min hold
.build()
);
sessionToken = response.sessionToken();
response.entityEvents().forEach(event ->
System.out.println("Event type=" + event.eventType() + " entity=" + event.entity()));
} catch (LatticeApiException e) {
System.err.println("Poll error: " + e.getMessage());
Thread.sleep(2000);
}
}
```
--------------------------------
### Fetch Object from Lattice SDK Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Fetches an object from your environment using the objectPath. Supports optional compression via acceptEncoding and priority headers.
```java
client.objects().getObject(
"objectPath",
GetObjectRequest
.builder()
.build()
);
```
--------------------------------
### Long Poll Entity Events
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
A long polling API to retrieve pre-existing and new entity data as it becomes available. Start a new session with an empty 'sessionToken'. Use the received session token to retrieve subsequent batches. The server holds connections for up to 5 minutes; no results will be returned on timeout. Sessions terminate if they fall behind by more than 3x the total number of entities.
--------------------------------
### Client Instantiation with Custom Base URL
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Set a custom base URL for API requests when constructing the client.
```java
import com.anduril.Lattice;
Lattice client = Lattice
.builder()
.url("https://example.com")
.build();
```
--------------------------------
### Initialize Synchronous Lattice Client with Bearer Token
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Build a synchronous Lattice client using a bearer token for authentication. Custom server hostnames, timeouts, retry counts, headers, and logging configurations can be specified.
```java
import com.anduril.Lattice;
import com.anduril.core.Environment;
import com.anduril.core.LogConfig;
import com.anduril.core.LogLevel;
// Option 1: Bearer token authentication with a custom server hostname
Lattice client = Lattice.builder()
.server("my-env.developer.anduril.com")
.token("my-access-token")
.timeout(120) // seconds; default is 60
.maxRetries(3) // default is 2
.addHeader("X-Request-Id", "req-001")
.logging(LogConfig.builder()
.level(LogLevel.DEBUG)
.silent(false)
.build())
.build();
```
--------------------------------
### Configure Custom OkHttp Client with Interceptors
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Configure a custom OkHttp client to add interceptors like HTTP logging and set connection/read timeouts. This client can then be provided to the Lattice client builder.
```java
import com.anduril.Lattice;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import java.util.concurrent.TimeUnit;
HttpLoggingInterceptor logger = new HttpLoggingInterceptor(System.err::println);
logger.setLevel(HttpLoggingInterceptor.Level.HEADERS);
OkHttpClient customHttp = new OkHttpClient.Builder()
.addInterceptor(logger)
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(300, TimeUnit.SECONDS)
.build();
Lattice client = Lattice.builder()
.url("https://my-env.developer.anduril.com")
.token("my-access-token")
.httpClient(customHttp)
.build();
```
--------------------------------
### List Objects in Lattice SDK Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Lists objects in your environment. Define a prefix to list a subset. By default, this endpoint lists local objects only.
```java
client.objects().listObjects(
ListObjectsRequest
.builder()
.build()
);
```
--------------------------------
### Create a New Task with Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Creates a new task in the system. This method sets the initial status and can assign the task to a specific agent. The task then enters its lifecycle workflow for further management.
```java
client.tasks().createTask(
TaskCreation
.builder()
.build()
);
```
--------------------------------
### client.tasks().listenAsAgent(request)
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Initiates a listening mechanism for agents, likely to receive task assignments or updates.
```APIDOC
## listenAsAgent request AgentRequest
### Description
Initiates a listening mechanism for agents.
### Method
client.tasks().listenAsAgent
### Parameters
(No parameters explicitly documented in the source for this method.)
```
--------------------------------
### Stream Entities in Real-Time with Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Establishes a server-sent events (SSE) connection to stream entity data in real-time. This is useful for maintaining a live view of operational data. Configure heartbeat intervals, pre-existing entity streaming, and specific components to include for optimization.
```java
client.entities().streamEntities(
EntityStreamRequest
.builder()
.build()
);
```
--------------------------------
### client.objects.listObjects()
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Lists objects in your environment. You can define a prefix to list a subset of your objects. If you do not set a prefix, Lattice returns all available objects. By default this endpoint will list local objects only.
```APIDOC
## client.objects.listObjects()
### Description
Lists objects in your environment. You can define a prefix to list a subset of your objects. If you do not set a prefix, Lattice returns all available objects. By default this endpoint will list local objects only.
### Parameters
#### Query Parameters
- **prefix** (Optional) - Filters the objects based on the specified prefix path. If no path is specified, all objects are returned.
- **sinceTimestamp** (Optional) - Sets the age for the oldest objects to query across the environment.
- **pageToken** (Optional) - Base64 and URL-encoded cursor returned by the service to continue paging.
- **allObjectsInMesh** (Optional) - Lists objects across all environment nodes in a Lattice Mesh.
- **maxPageSize** (Optional) - Sets the maximum number of items that should be returned on a single page.
### Usage Example
```java
client.objects().listObjects(
ListObjectsRequest
.builder()
.build()
);
```
```
--------------------------------
### Stream Manual Control Frames for a Task
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Establishes a server streaming connection using SSE to deliver manual control frames, such as joystick movements, for a specific task. The agent should open this stream before reporting STATUS_EXECUTING to be ready for control input. The stream includes metadata for frame handling and heartbeats, and terminates when the task reaches a terminal state.
```java
client.tasks().streamManualControlFrames(
"taskId",
ManualControlStreamRequest
.builder()
.build()
);
```
--------------------------------
### Stream Tasks as an Agent using SSE
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Establishes a server streaming connection using Server-Sent Events (SSE) to deliver tasks to agents. This is the recommended method for real-time task processing. It supports Execute, Cancel, and Complete requests, along with periodic heartbeat messages to maintain the connection.
```java
client.tasks().streamAsAgent(
AgentStreamRequest
.builder()
.build()
);
```
--------------------------------
### Authentication with OAuth Client Credentials
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Configure the client with OAuth client ID and secret for automatic token management.
```java
Lattice client = Lattice.builder()
.credentials("client-id", "client-secret")
.url("https://api.example.com")
.build();
```
--------------------------------
### Download Object with Gzip Compression
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Fetches the raw bytes of an object as an InputStream. Supports optional gzip compression via `acceptEncoding`. Ensure the destination path exists and is writable.
```java
import com.anduril.resources.objects.requests.GetObjectRequest;
import com.anduril.resources.objects.types.GetObjectRequestAcceptEncoding;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
InputStream stream = client.objects().getObject(
"missions/2024/sector7-plan.bin",
GetObjectRequest.builder()
.acceptEncoding(GetObjectRequestAcceptEncoding.GZIP)
.build()
);
Path dest = Path.of("/tmp/sector7-plan.bin");
Files.copy(stream, dest);
System.out.println("Downloaded to " + dest);
```
--------------------------------
### Download an object
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Fetches the raw bytes of an object as an InputStream. Supports optional gzip compression via acceptEncoding.
```APIDOC
## client.objects().getObject(objectPath, request) — Download an object
### Description
Fetches the raw bytes of an object as an `InputStream`. Supports optional gzip compression via `acceptEncoding`.
### Method
```java
InputStream stream = client.objects().getObject(
"missions/2024/sector7-plan.bin",
GetObjectRequest.builder()
.acceptEncoding(GetObjectRequestAcceptEncoding.GZIP)
.build()
);
Path dest = Path.of("/tmp/sector7-plan.bin");
Files.copy(stream, dest);
System.out.println("Downloaded to " + dest);
```
```
--------------------------------
### client.objects.getObject(objectPath)
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Fetches an object from your environment using the objectPath path parameter.
```APIDOC
## client.objects.getObject(objectPath)
### Description
Fetches an object from your environment using the objectPath path parameter.
### Parameters
#### Path Parameters
- **objectPath** (String) - The path of the object to fetch.
#### Query Parameters
- **acceptEncoding** (Optional) - If set, Lattice will compress the response using the specified compression method. If the header is not defined, or the compression method is set to `identity`, no compression will be applied to the response.
- **priority** (Optional) - Indicates a client's preference for the priority of the response. The value is a structured header as defined in RFC 9218. If you do not set the header, Lattice uses the default priority set for the environment. Incremental delivery directives are not supported and will be ignored.
### Usage Example
```java
client.objects().getObject(
"objectPath",
GetObjectRequest
.builder()
.build()
);
```
```
--------------------------------
### Create a new task
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Creates a task with STATUS_CREATED. Optionally supply a custom taskId matching [A-Za-z0-9_-.]{5,36}; otherwise a UUID is generated. Assign the task to an agent via the relations field. The specification field expects a GoogleProtobufAny with the task definition.
```java
import com.anduril.types.TaskCreation;
import com.anduril.types.Task;
Task task = client.tasks().createTask(
TaskCreation.builder()
.taskId("mission-task-001")
.displayName("Patrol sector 7")
.description("Autonomous patrol of grid sector 7 at altitude 300m")
// .specification(...) // GoogleProtobufAny with task definition
// .relations(...) // assign to a specific agent entity
.build()
);
System.out.println("Created task id=" + task.taskId() + " status=" + task.status());
```
--------------------------------
### List objects with optional prefix filter
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Returns paginated PathMetadata for objects in the environment. Optionally scope to a prefix or a time window. Set allObjectsInMesh to list across all Lattice Mesh nodes.
```APIDOC
## client.objects().listObjects(request) — List objects with optional prefix filter
### Description
Returns paginated `PathMetadata` for objects in the environment. Optionally scope to a prefix or a time window. Set `allObjectsInMesh` to list across all Lattice Mesh nodes.
### Method
```java
SyncPagingIterable objects = client.objects().listObjects(
ListObjectsRequest.builder()
.prefix("missions/2024/")
.maxPageSize(50)
.allObjectsInMesh(false)
.build()
);
for (PathMetadata meta : objects) {
System.out.println("Object: " + meta.path() + " size=" + meta.sizeBytes());
}
```
```
--------------------------------
### client.tasks().listenAsAgent
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Establishes a server streaming connection that delivers tasks to taskable agents for execution. This method creates a persistent connection from Tasks API to an agent, allowing the server to push tasks to the agent as they become available. The stream delivers ExecuteRequest, CancelRequest, and CompleteRequest. This is a long polling API that will block until a new task is ready for delivery, with a timeout of 5 minutes.
```APIDOC
## listenAsAgent
### Description
Establishes a server streaming connection that delivers tasks to taskable agents for execution.
This method creates a persistent connection from Tasks API to an agent, allowing the server
to push tasks to the agent as they become available. The agent receives a stream of tasks that
match its selector criteria (entity IDs).
The stream delivers three types of requests:
- ExecuteRequest: Contains a new task for the agent to execute
- CancelRequest: Indicates a task should be canceled
- CompleteRequest: Indicates a task should be completed
This is the primary method for taskable agents to receive and process tasks in real-time.
Agents should maintain this connection and process incoming tasks according to their capabilities.
When an agent receives a task, it should update the task status using the UpdateStatus endpoint
to provide progress information back to Tasks API.
This is a long polling API that will block until a new task is ready for delivery. If no new task is
available then the server will hold on to your request for up to 5 minutes, after that 5 minute timeout
period you will be expected to reinitiate a new request.
### Method
POST (Implied by client usage)
### Endpoint
/tasks/listenAsAgent (Implied by client usage)
### Parameters
#### Request Body
- **agentSelector** (Optional) - Optional - Selector criteria to determine which Agent Tasks the agent receives
```
--------------------------------
### Upload an object
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Uploads a byte array as an object. The object must be 1 GiB or smaller.
```APIDOC
## client.objects().uploadObject(objectPath, data) — Upload an object
### Description
Uploads a byte array as an object. The object must be 1 GiB or smaller.
### Method
```java
byte[] data = Files.readAllBytes(Path.of("/tmp/sensor-data.bin"));
PathMetadata meta = client.objects().uploadObject(
"sensor-feeds/2024/sensor-data.bin",
data
);
System.out.println("Uploaded: path=" + meta.path() + " size=" + meta.sizeBytes());
```
```
--------------------------------
### Upload Object in Lattice SDK Java
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Uploads an object to your environment. The object must be 1 GiB or smaller.
```java
client.objects().uploadObject("", "".getBytes());
```
--------------------------------
### client.entities.publishEntity(request)
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Publishes an entity for ingest into the Entities API. Creates the entity if it does not exist, or updates it if it does and the new entity's provenance.sourceUpdateTime is greater than the existing entity's.
```APIDOC
## publishEntity(request)
### Description
Publishes an entity for ingest into the Entities API. Entities created with this method are "owned" by the originator: other sources, such as the UI, may not edit or delete these entities. The server validates entities at API call time and returns an error if the entity is invalid.
An entity ID must be provided when calling this endpoint. If the entity referenced by the entity ID does not exist then it will be created. Otherwise the entity will be updated. An entity will only be updated if its provenance.sourceUpdateTime is greater than the provenance.sourceUpdateTime of the existing entity.
### Method
(Implicitly POST or PUT based on description of create/update)
### Endpoint
(Not specified, assumed to be related to entities)
### Parameters
#### Request Body
- **request**: `Entity` - The entity object to publish.
### Request Example
```java
client.entities().publishEntity(
Entity
.builder()
.build()
);
```
### Response
#### Success Response (200)
- **Entity**: The published or updated entity.
```
--------------------------------
### Authentication Parameters
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
These parameters are used for authentication when interacting with the Lattice API.
```APIDOC
## Parameters
### Grant Type
- **grantType** (String) - Required - The type of grant being requested.
### Client ID
- **clientId** (Optional) - Optional - The client identifier.
### Client Secret
- **clientSecret** (Optional) - Optional - The client secret.
```
--------------------------------
### client.objects.uploadObject(objectPath, request)
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Uploads an object. The object must be 1 GiB or smaller.
```APIDOC
## client.objects.uploadObject(objectPath, request)
### Description
Uploads an object. The object must be 1 GiB or smaller.
### Parameters
#### Path Parameters
- **objectPath** (String) - Path of the Object that is to be uploaded.
### Usage Example
```java
client.objects().uploadObject("", "".getBytes());
```
```
--------------------------------
### Authentication with Bearer Token
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Configure the client with a direct bearer token and API URL for authentication.
```java
Lattice client = Lattice.builder()
.token("your-access-token")
.url("https://api.example.com")
.build();
```
--------------------------------
### Maven Dependency for Lattice SDK
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Add this dependency to your pom.xml file to include the Lattice SDK.
```xml
com.andurillattice-sdk5.7.1
```
--------------------------------
### Access Raw Response Data with Lattice SDK
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Use the `withRawResponse()` method to obtain a raw client that provides access to the full `LatticeHttpResponse`, including `body()` and `headers()`. This is useful when you need to inspect response headers or the raw body content.
```java
LatticeHttpResponse response = client.entities().withRawResponse().longPollEntityEvents(...);
System.out.println(response.body());
System.out.println(response.headers().get("X-My-Header"));
```
--------------------------------
### Upload Object
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Uploads a byte array as an object to the environment. The object size must be 1 GiB or smaller. The `data` byte array is read from the specified file path.
```java
import com.anduril.types.PathMetadata;
import java.nio.file.Files;
import java.nio.file.Path;
byte[] data = Files.readAllBytes(Path.of("/tmp/sensor-data.bin"));
PathMetadata meta = client.objects().uploadObject(
"sensor-feeds/2024/sensor-data.bin",
data
);
System.out.println("Uploaded: path=" + meta.path() + " size=" + meta.sizeBytes());
```
--------------------------------
### Gradle Dependency for Lattice SDK
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Add this dependency to your build.gradle file to include the Lattice SDK.
```groovy
// build.gradle
dependencies {
implementation 'com.anduril:lattice-sdk:5.7.1'
}
```
--------------------------------
### Configuring Client-Level Timeout
Source: https://github.com/anduril/lattice-sdk-java/blob/master/README.md
Set the default timeout for all client requests.
```java
import com.anduril.Lattice;
Lattice client = Lattice
.builder()
.timeout(60)
.build();
```
--------------------------------
### Search Tasks with Filtering using client.tasks().queryTasks
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Returns paginated tasks filtered by parent ID, status, update-time range, or assignee. Use `pageToken` for pagination.
```java
import com.anduril.types.TaskQuery;
import com.anduril.types.TaskQueryResults;
TaskQueryResults results = client.tasks().queryTasks(
TaskQuery.builder()
// .statusFilter(...) // inclusive or exclusive status filter
// .updateTimeRange(...) // time-range filter
// .parentTaskId("parent-001") // mutually exclusive with other filters
.build()
);
results.tasks().forEach(t ->
System.out.println("Task: " + t.taskId() + " status=" + t.status()));
// Paginate
if (results.pageToken() != null) {
TaskQueryResults page2 = client.tasks().queryTasks(
TaskQuery.builder().pageToken(results.pageToken()).build()
);
}
```
--------------------------------
### Query Tasks with Java SDK
Source: https://github.com/anduril/lattice-sdk-java/blob/master/reference.md
Search for tasks using various filtering criteria. Results are paginated, and a page_token can be used to retrieve subsequent results. This method is suitable for retrieving a list of tasks based on their properties.
```java
client.tasks().queryTasks(
TaskQuery
.builder()
.build()
);
```
--------------------------------
### createTask
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Creates a task with `STATUS_CREATED`. Optionally supply a custom `taskId` matching `[A-Za-z0-9_-.]{5,36}`; otherwise a UUID is generated. Assign the task to an agent via the `relations` field.
```APIDOC
## createTask
### Description
Creates a task with `STATUS_CREATED`. Optionally supply a custom `taskId` matching `[A-Za-z0-9_-.]{5,36}`; otherwise a UUID is generated. Assign the task to an agent via the `relations` field.
### Method
```java
client.tasks().createTask(request)
```
### Parameters
- **request** (TaskCreation) - Required - The details for the new task.
- **taskId** (string) - Optional - A custom task ID (5-36 characters, alphanumeric, underscore, dot, hyphen). If not provided, a UUID is generated.
- **displayName** (string) - Required - A human-readable name for the task.
- **description** (string) - Optional - A detailed description of the task.
- **specification** (GoogleProtobufAny) - Optional - The task's specific definition or parameters.
- **relations** (object) - Optional - Defines relationships, such as assigning the task to an agent.
### Request Example
```java
import com.anduril.types.TaskCreation;
import com.anduril.types.Task;
Task task = client.tasks().createTask(
TaskCreation.builder()
.taskId("mission-task-001")
.displayName("Patrol sector 7")
.description("Autonomous patrol of grid sector 7 at altitude 300m")
// .specification(...) // GoogleProtobufAny with task definition
// .relations(...) // assign to a specific agent entity
.build()
);
System.out.println("Created task id=" + task.taskId() + " status=" + task.status());
```
### Response
#### Success Response (200)
- **Task** (Task) - The created task object, including its ID and status.
```
--------------------------------
### Report Task Progress with client.tasks().updateTaskStatus
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Agents use this to report status changes. Provide the current `statusVersion` to prevent race conditions. Terminal states `STATUS_DONE_OK` / `STATUS_DONE_NOT_OK` are permanent.
```java
import com.anduril.resources.tasks.requests.TaskStatusUpdate;
import com.anduril.types.Task;
import com.anduril.types.TaskStatus;
Task updated = client.tasks().updateTaskStatus(
"mission-task-001",
TaskStatusUpdate.builder()
.statusVersion(1) // must match current server version
.newStatus(TaskStatus.STATUS_EXECUTING)
.build()
);
System.out.println("New status: " + updated.status() + " version: " + updated.statusVersion());
```
--------------------------------
### Per-Request Options for Timeout and Custom Headers
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Utilize `RequestOptions` to override timeout and headers on a per-call basis without needing to re-build the client. This allows for fine-grained control over individual requests.
```java
import com.anduril.core.RequestOptions;
import com.anduril.resources.entities.requests.EntityStreamRequest;
import java.util.concurrent.TimeUnit;
Iterable> stream = client.entities().streamEntities(
EntityStreamRequest.builder().build(),
RequestOptions.builder()
.timeout(300, TimeUnit.SECONDS)
.addHeader("X-Correlation-Id", "trace-abc-789")
.addQueryParameter("debug", "true")
.build()
);
```
--------------------------------
### Raw response access — reading response headers
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Use `withRawResponse()` on any resource client to access HTTP headers alongside the response body.
```APIDOC
## Raw response access — reading response headers
### Description
Use `withRawResponse()` on any resource client to access HTTP headers alongside the response body.
### Method
```java
LatticeHttpResponse response = client.entities()
.withRawResponse()
.longPollEntityEvents(
EntityEventRequest.builder()
.sessionToken("")
.build()
);
System.out.println("Body: " + response.body());
System.out.println("X-Request-Id: " + response.headers().get("X-Request-Id"));
```
```
--------------------------------
### List Objects with Prefix Filter
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
Use to retrieve paginated metadata for objects within an environment, optionally filtering by a prefix or time window. Set `allObjectsInMesh` to true to list across all Lattice Mesh nodes.
```java
import com.anduril.resources.objects.requests.ListObjectsRequest;
import com.anduril.core.pagination.SyncPagingIterable;
import com.anduril.types.PathMetadata;
SyncPagingIterable objects = client.objects().listObjects(
ListObjectsRequest.builder()
.prefix("missions/2024/")
.maxPageSize(50)
.allObjectsInMesh(false)
.build()
);
for (PathMetadata meta : objects) {
System.out.println("Object: " + meta.path() + " size=" + meta.sizeBytes());
}
```
--------------------------------
### client.tasks().streamAsAgent(request)
Source: https://context7.com/anduril/lattice-sdk-java/llms.txt
The recommended method for agents to receive tasks via SSE. It streams Execute, Cancel, and Complete requests, along with periodic heartbeats.
```APIDOC
## `client.tasks().streamAsAgent(request)` — SSE stream as a taskable agent (recommended)
The recommended way for agents to receive tasks. Streams Execute, Cancel, and Complete requests plus periodic heartbeats.
### Parameters
#### Request Body
- **request** (AgentStreamRequest) - Required - Configuration for the agent stream.
- **heartbeatIntervalMs** (long) - Optional - Interval in milliseconds for sending heartbeat events.
- **agentSelector** (EntityIdsSelector) - Optional - Selects specific agents to stream tasks for.
### Response
#### Success Response (200)
- **Iterable