For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Logo
ContactLearn More
GuidesReferenceSamplesLicenseChangelog
GuidesReferenceSamplesLicenseChangelog
  • Concepts
    • Overview
    • Principles
  • Getting started
    • Set up
    • Authenticate
    • Quickstart
  • Best practices
    • Choose a protocol
    • Connect offline
    • Retry connections
  • Developer tools
    • Sandboxes
  • Entities
    • Overview
    • Watch
    • Publish
  • Tasks
    • Overview
    • Operate
    • Listen
    • Update
  • Objects
    • Overview
    • Upload
    • Download
    • Manage
ContactLearn More
On this page
  • Before you begin
  • Get object metadata
  • Set object time-to-live
  • Delete an object
  • What’s next?
Objects

Manage objects

Getting metadata, and managing the lifecycle of objects using the Lattice SDK
Previous

In Lattice, an object is a data model that represents a single file or a piece of data. This page explains how to manage objects in Lattice, including retrieving metadata, setting expiration times, and deleting objects.

Before you begin

  • To configure your app to manage objects, set up your Lattice environment.
  • See an overview of the Object schema and the Object Store API in Lattice.
  • If you haven’t already, learn how to upload and download objects.
gRPC authentication

If you are using gRPC with client credentials, set up the token refresh module before running the examples on this page.

Get object metadata

To retrieve metadata about an object without downloading its contents, use the getObjectMetadata method, which performs a HEAD request to the server.

This operation returns metadata such as the object size in bytes, the SHA-256 checksum, and timestamps indicating when the object was last modified, and when it expires.

1

Specify the object path

When using the GetObjectMetadata API, you must specify the object path of the object for which you want to retrieve metadata.

For example, if you previously uploaded an image at /api/v1/objects/image.jpg, you would use this path to request its metadata.

2

Get the object metadata

Run the following code to retrieve the object’s metadata. Replace objectPath with the path of the object.

1// Example code for getting object metadata
2package main
3
4import (
5 "context"
6 "fmt"
7 "os"
8
9 Lattice "github.com/anduril/lattice-sdk-go/v4"
10 "github.com/anduril/lattice-sdk-go/v4/client"
11 "github.com/anduril/lattice-sdk-go/v4/option"
12)
13
14func main() {
15 // Get environment variables
16 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
17 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
18 clientId := os.Getenv("LATTICE_CLIENT_ID")
19
20 // Remove sandboxesToken from the following statements if you are not developing on Sandboxes
21 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
22
23 // Check required environment variables
24 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
25 fmt.Println("Missing required environment variables")
26 os.Exit(1)
27 }
28
29 // Initialize headers for sandbox authorization
30 headers := make(map[string][]string)
31 headers["Anduril-Sandbox-Authorization"] = []string{fmt.Sprintf("Bearer %s", sandboxesToken)}
32
33 // Create the client
34 c := client.NewClient(
35 option.WithClientCredentials(clientId, clientSecret),
36 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
37 option.WithHTTPHeader(headers),
38 )
39 // Set object path
40 objectPath := "<OBJECT_PATH>"
41
42 // Create context for the request
43 ctx := context.Background()
44
45 // Get the object metadata using HEAD request
46 response, err := c.Objects.WithRawResponse.GetObjectMetadata(ctx, &Lattice.GetObjectMetadataRequest{ObjectPath: objectPath})
47 if err != nil {
48 fmt.Printf("Error getting object metadata: %v\n", err)
49 os.Exit(1)
50 }
51
52 // The response contains headers with metadata information
53 fmt.Println("Object Metadata:")
54 fmt.Printf("Status Code: %d\n", response.StatusCode)
55 fmt.Printf("Path: %s\n", response.Header.Get("Path"))
56 fmt.Printf("Content-Length: %s bytes\n", response.Header.Get("Content-Length"))
57 fmt.Printf("Checksum: %s\n", response.Header.Get("Checksum"))
58 fmt.Printf("Last-Modified: %s\n", response.Header.Get("Last-Modified"))
59 fmt.Printf("Expires: %s\n", response.Header.Get("Expires"))
60 fmt.Println("Object metadata retrieved successfully")
61}
3

Inspect the metadata

If successful, the response will include headers with valuable information:

$Object metadata:
$- Path: your_object_path.jpg
$- Content-Length: 2000000 bytes
$- Checksum: 4191337226643912nbab1784de94c4f58bb78bf98bfb9916474b2fe5decbbaa6
$- Last-Modified: Thu, 30 Oct 2025 00:30:41 UTC
$- Expires: Thu, 30 Oct 2025 01:30:41 UTC

You can use this information to verify the object size before downloading, confirm the object hasn’t been modified using the checksum, and check when the object expires and is removed from your environment.

Set object time-to-live

In Lattice, an object is a data model that represents a single file or a piece of data. When uploading objects, you can control how long they will be stored in Lattice by setting a Time-To-Live (TTL) value. This is useful for temporary files or for implementing storage policies.

1

Prepare the file and TTL value

Before uploading, you need to:

  1. Have a file ready to upload
  2. Determine the desired time-to-live in nanoseconds

For example, to keep an object for 24 hours, you would set the TTL to: 24 * 60 * 60 * 1,000,000,000 nanoseconds (86,400,000,000,000 ns)

2

Upload with TTL header

Use the Lattice SDK to upload the object, adding the Time-To-Live request header to specify the TTL:

1package main
2
3import (
4 "bytes"
5 "context"
6 "fmt"
7 "net/http"
8 "os"
9 "path/filepath"
10 "strconv"
11
12 Lattice "github.com/anduril/lattice-sdk-go/v4"
13 "github.com/anduril/lattice-sdk-go/v4/client"
14 "github.com/anduril/lattice-sdk-go/v4/option"
15)
16
17func main() {
18 // Get environment variables
19 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
20 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
21 clientId := os.Getenv("LATTICE_CLIENT_ID")
22
23 // Remove sandboxesToken from the following statements if you are not developing on Sandboxes
24 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
25
26 // Check required environment variables
27 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
28 fmt.Println("Missing required environment variables")
29 os.Exit(1)
30 }
31
32 // Initialize headers for sandbox authorization
33 headers := http.Header{}
34 headers.Add("Anduril-Sandbox-Authorization", fmt.Sprintf("Bearer %s", sandboxesToken))
35
36 // Create the client
37 c := client.NewClient(
38 option.WithClientCredentials(clientId, clientSecret),
39 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
40 option.WithHTTPHeader(headers),
41 )
42
43 // File path of the object to upload
44 filePath := "<FILE_PATH_TTL>"
45
46 // Set TTL to 1 hour in nanoseconds
47 ttlInNanoseconds := int64(1 * 60 * 60 * 1000000000) // 1 hour in nanoseconds
48
49 // Create context for the request
50 ctx := context.Background()
51
52 // Read the file contents into a byte slice.
53 fileContent, err := os.ReadFile(filePath)
54 if err != nil {
55 fmt.Printf("Error reading file: %v\n", err)
56 os.Exit(1)
57 }
58
59 // Get file name for object path
60 objectPath := filepath.Base(filePath)
61
62 // Create TTL header
63 ttlHeaders := http.Header{}
64 ttlHeaders.Add("Time-To-Live", strconv.FormatInt(ttlInNanoseconds, 10))
65
66 // Upload object with TTL header
67 response, err := c.Objects.UploadObject(
68 ctx,
69 objectPath,
70 bytes.NewReader(fileContent),
71 option.WithHTTPHeader(ttlHeaders),
72 )
73 if err != nil {
74 fmt.Printf("Error uploading object: %v\n", err)
75 os.Exit(1)
76 }
77
78 fmt.Printf("Object uploaded successfully. Object path: %s\n", response.ContentIdentifier.Path)
79 fmt.Printf("Object will expire after %d seconds\n", ttlInNanoseconds/1000000000)
80
81 // Verify the expiry time by getting object metadata
82 metadataResponse, err := c.Objects.WithRawResponse.GetObjectMetadata(ctx, &Lattice.GetObjectMetadataRequest{ObjectPath: objectPath})
83 if err != nil {
84 fmt.Printf("Error getting object metadata: %v\n", err)
85 os.Exit(1)
86 }
87
88 fmt.Printf("Expiry time confirmed: %s\n", metadataResponse.Header.Get("Expires"))
89}
3

Verify the expiry time

If successful, Lattice sets an expiry time based on the value you specify in the Time-To-Live header. The example from the previous steps confirms the result by fetching the object’s metadata and checking the Expires header:

$Object expires on Mon, 01 Jan 2026 00:00:00 UTC

If you don’t set a TTL, Lattice will use a default typically set to 90 days. This default TTL policy might vary, based on your environment’s configurations.

Delete an object

In Lattice, an object is a data model that represents a single file or a piece of data. When you no longer need an object, you can delete it from Lattice to free up storage space. Deleting an object is a permanent operation that cannot be undone.

1

Delete the object

When using the DeleteObject API, you must specify the object path of the object you want to delete.

Replace the object path with your information, then run the following code to delete the object:

1// Example code for deleting an object
2package main
3
4import (
5 "context"
6 "fmt"
7 "os"
8
9 Lattice "github.com/anduril/lattice-sdk-go/v4"
10 "github.com/anduril/lattice-sdk-go/v4/client"
11 "github.com/anduril/lattice-sdk-go/v4/option"
12)
13
14func main() {
15 // Get environment variables
16 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
17 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
18 clientId := os.Getenv("LATTICE_CLIENT_ID")
19
20 // Remove sandboxesToken from the following statements if you are not developing on Sandboxes
21 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
22
23 // Check required environment variables
24 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
25 fmt.Println("Missing required environment variables")
26 os.Exit(1)
27 }
28
29 // Initialize headers for sandbox authorization
30 headers := make(map[string][]string)
31 headers["Anduril-Sandbox-Authorization"] = []string{fmt.Sprintf("Bearer %s", sandboxesToken)}
32
33 // Create the client
34 c := client.NewClient(
35 option.WithClientCredentials(clientId, clientSecret),
36 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
37 option.WithHTTPHeader(headers),
38 )
39 // Set object path to delete
40 objectPath := "<DELETE_OBJECT_PATH>"
41
42 // Create context for the request
43 ctx := context.Background()
44
45 // Delete the object
46 err := c.Objects.DeleteObject(ctx, &Lattice.DeleteObjectRequest{ObjectPath: objectPath})
47 if err != nil {
48 fmt.Printf("Error deleting object: %v\n", err)
49 os.Exit(1)
50 }
51
52 fmt.Printf("Object deleted successfully: %s\n", objectPath)
53
54 // Try to access the object to verify it's deleted
55 _, err = c.Objects.WithRawResponse.GetObjectMetadata(ctx, &Lattice.GetObjectMetadataRequest{ObjectPath: objectPath})
56 if err != nil {
57 fmt.Println("Verification successful: Object no longer exists.")
58 fmt.Printf("Expected error: %v\n", err)
59 } else {
60 fmt.Println("Warning: Object still exists after deletion attempt.")
61 }
62}

If successful, this produces an error with the following output: the object no longer exists”

$Object deleted successfully: test.jpg
$Status: 404
2

(Optional) Unlink entity

When you delete an object, you must clean up any references to the object path in your environment.

For example, if the object is linked to an entity, using the entity’s Media component, your app must submit an Override to remove the object path from the list. Run the following example:

1package main
2
3import (
4 "context"
5 "fmt"
6 "net/http"
7 "os"
8 "time"
9
10 Lattice "github.com/anduril/lattice-sdk-go/v4"
11 "github.com/anduril/lattice-sdk-go/v4/client"
12 "github.com/anduril/lattice-sdk-go/v4/option"
13)
14
15func main() {
16 // Get environment variables
17 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
18 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
19 clientId := os.Getenv("LATTICE_CLIENT_ID")
20 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
21
22 // Check required environment variables
23 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
24 fmt.Println("Make sure your Lattice URL and bearer token have been set as system environment variables.")
25 os.Exit(1)
26 }
27
28 // Initialize headers for sandbox authorization
29 headers := http.Header{}
30 headers.Add("Anduril-Sandbox-Authorization", fmt.Sprintf("Bearer %s", sandboxesToken))
31
32 // Create the client
33 LatticeClient := client.NewClient(
34 option.WithClientCredentials(clientId, clientSecret),
35 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
36 option.WithHTTPHeader(headers),
37 )
38
39 // Set the entity ID
40 entityID := "<ENTITY_ID>"
41
42 // Create context for the request
43 ctx := context.Background()
44
45 // Create empty media array
46 media := Lattice.Media{
47 Media: []*Lattice.MediaItem{},
48 }
49
50 // Create a provenance object
51 latestTimestamp := time.Now().UTC()
52
53 // Create an entity with empty media
54 entityOverride := Lattice.EntityOverride{
55 EntityID: entityID,
56 FieldPath: "media.media",
57 Entity: &Lattice.Entity{
58 EntityID: &entityID,
59 Media: &media,
60 },
61 Provenance: &Lattice.Provenance{
62 IntegrationName: Lattice.String("<your_integration_name>"),
63 DataType: Lattice.String("<your_data_type>"),
64 SourceUpdateTime: Lattice.Time(latestTimestamp),
65 },
66 }
67
68 // Override the entity's media field
69 _, err := LatticeClient.Entities.OverrideEntity(
70 ctx,
71 &entityOverride,
72 )
73
74 if err != nil {
75 fmt.Printf("Exception: %v\n", err)
76 return
77 }
78
79 // Get the entity to verify the media was cleared
80 entity, err := LatticeClient.Entities.GetEntity(
81 ctx,
82 &Lattice.GetEntityRequest{EntityID: entityID},
83 )
84
85 if err != nil {
86 fmt.Printf("Failed to get entity: %v\n", err)
87 return
88 }
89
90 fmt.Printf("Entity: %s\n", *entity.EntityID)
91 if entity.Media != nil && entity.Media.Media != nil {
92 fmt.Printf("Media: %v\n", entity.Media.Media)
93 } else {
94 fmt.Printf("Media: None\n")
95 }
96}

If successful, you’ll see an output similar to the following, confirming that the entity’s Media component is empty

$Entity: <your_entity_id>
$Media: None

What’s next?

  • Learn more about the Objects API.
  • Explore how to use objects with Entities to associate binary data with your Lattice entities.