The examples on this page demonstrate how to create individual objects in Weaviate.

:::callout{intent="tip" title="Use batch import for multiple objects"}
For creating multiple objects at once, see [How-to: Batch Import](import.md).
:::

## Create an object

This example creates an object in the `JeopardyQuestion` collection.

:::code-group{sync="languages"}
```python title="Python" {3}
jeopardy = client.collections.use("JeopardyQuestion")

uuid = jeopardy.data.insert({
    "question": "This vector DB is OSS & supports automatic property type inference on import",
    # "answer": "Weaviate",  # properties can be omitted
    "newProperty": 123,  # will be automatically added as a number property
})

print(uuid)  # the return value is the object's UUID
```

```typescript title="JavaScript/TypeScript"
const jeopardy = client.collections.use('JeopardyQuestion')
```

```go title="Go"
w, err := client.Data().Creator().
  WithClassName("JeopardyQuestion").
  WithProperties(map[string]interface{}{
    "question": "This vector DB is OSS and supports automatic property type inference on import",
    // "answer": "Weaviate", // schema properties can be omitted
    "newProperty": 123, // will be automatically added as a number property
  }).
  Do(ctx)
```

```java title="Java" {3}
var jeopardy = client.collections.use("JeopardyQuestion");

var uuid = jeopardy.data.insert(Map.of(
    "question",
    "This vector DB is OSS & supports automatic property type inference on import",
    // "answer": "Weaviate", // properties can be omitted
    "newProperty", 123 // will be automatically added as a number property
)).uuid();

System.out.println(uuid); // the return value is the object's UUID
```

```csharp title="C#" {3-5}
var jeopardy = client.Collections.Use("JeopardyQuestion");

var uuid = await jeopardy.Data.Insert(
    new
    {
        question = "This vector DB is OSS & supports automatic property type inference on import",
        // answer = "Weaviate", // properties can be omitted
        newProperty = 123, // will be automatically added as a number property
    }
);

Console.WriteLine(uuid); // the return value is the object's UUID
```
:::

:::accordion{title="Additional information"}
To create an object, specify the following:

- The object data you want to add
- The target collection
- If [multi-tenancy](../concepts/data.md#multi-tenancy) is enabled, [specify the tenant](../how-to-manage-collections/multi-tenancy.md)

By default, [auto-schema](../reference-configuration/collections.md#auto-schema) creates new collections and adds new properties.
:::

## Create an object with a specified vector

When you create an object, you can provide a vector. (For specifying multiple, named vectors, see [below](#create-an-object-with-named-vectors).)

:::code-group{sync="languages"}
```python title="Python" {7}
jeopardy = client.collections.use("JeopardyQuestion")
uuid = jeopardy.data.insert(
    properties={
        "question": "This vector DB is OSS and supports automatic property type inference on import",
        "answer": "Weaviate",
    },
    vector=[0.12345] * 1536
)

print(uuid)  # the return value is the object's UUID
```

```typescript title="JavaScript/TypeScript"
const jeopardy = client.collections.use('JeopardyQuestion')
```

```go title="Go" {12}
vector := make([]float32, 1536)
for i := 0; i < len(vector); i++ {
  vector[i] = 0.12345
}

w, err := client.Data().Creator().
  WithClassName("JeopardyQuestion").
  WithProperties(map[string]interface{}{
    "question": "This vector DB is OSS and supports automatic property type inference on import",
    "answer":   "Weaviate",
  }).
  WithVector(vector).
  Do(ctx)
```

```java title="Java" {5}
var jeopardy = client.collections.use("JeopardyQuestion");
var uuid = jeopardy.data.insert(Map.of("question",
    "This vector DB is OSS and supports automatic property type inference on import",
    "answer", "Weaviate"),
    meta -> meta.vectors(Vectors.of(new float[384])) // Using a zero vector for demonstration
).uuid();

System.out.println(uuid); // the return value is the object's UUID
```

```csharp title="C#" {8-9}
var jeopardy = client.Collections.Use("JeopardyQuestion");
var uuid = await jeopardy.Data.Insert(
    new
    {
        question = "This vector DB is OSS and supports automatic property type inference on import",
        answer = "Weaviate",
    },
    vectors: new float[300] // Using a zero vector for demonstration
);

Console.WriteLine(uuid); // the return value is the object's UUID
```
:::

## Create an object with named vectors

When you create an object, you can specify named vectors (if [configured in your collection](../how-to-manage-collections/vector-config.md#define-named-vectors)).

:::code-group{sync="languages"}
```python title="Python" {8-13}
reviews = client.collections.use("WineReviewNV")  # This collection must have named vectors configured
uuid = reviews.data.insert(
    properties={
        "title": "A delicious Riesling",
        "review_body": "This wine is a delicious Riesling which pairs well with seafood.",
        "country": "Germany",
    },
    # Specify the named vectors, following the collection definition
    vector={
        "title": [0.12345] * 1536,
        "review_body": [0.31313] * 1536,
        "title_country": [0.05050] * 1536,
    }
)

print(uuid)  # the return value is the object's UUID
```

```typescript title="JavaScript/TypeScript"
const reviews = client.collections.use('WineReviewNV')
```

```java title="Java" {6-9}
var reviews = client.collections.use("WineReviewNV"); // This collection must have named vectors configured
var uuid = reviews.data.insert(
    Map.of("title", "A delicious Riesling", "review_body",
        "This wine is a delicious Riesling which pairs well with seafood.",
        "country", "Germany"),
    // Specify the named vectors, following the collection definition
    meta -> meta.vectors(Vectors.of("title", new float[1536]),
        Vectors.of("review_body", new float[1536]),
        Vectors.of("title_country", new float[1536]))
).uuid();

System.out.println(uuid); // the return value is the object's UUID
```

```csharp title="C#" {9-16}
var reviews = client.Collections.Use("WineReviewNV"); // This collection must have named vectors configured
var uuid = await reviews.Data.Insert(
    new
    {
        title = "A delicious Riesling",
        review_body = "This wine is a delicious Riesling which pairs well with seafood.",
        country = "Germany",
    },
    // Specify the named vectors, following the collection definition
    vectors: new Vectors
    {
        { "title", new float[1536] },
        { "review_body", new float[1536] },
        { "title_country", new float[1536] },
    }
);

Console.WriteLine(uuid); // the return value is the object's UUID
```
:::

## Create an object with a specified ID

When you create an object, you can specify an [ID](../apis/graphql-additional-properties.md#id).

:::callout{intent="info"}
If no ID is provided, Weaviate will generate a random [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
:::

:::code-group{sync="languages"}
```python title="Python" {8}
properties = {
    "question": "This vector DB is OSS and supports automatic property type inference on import",
    "answer": "Weaviate",
}
jeopardy = client.collections.use("JeopardyQuestion")
uuid = jeopardy.data.insert(
    properties=properties,
    uuid="12345678-e64f-5d94-90db-c8cfa3fc1234"
)

print(uuid)  # the return value is the object's UUID
```

```typescript title="JavaScript/TypeScript"
const jeopardy = client.collections.use('JeopardyQuestion')
```

```go title="Go" {12}
vector := make([]float32, 1536)
for i := 0; i < len(vector); i++ {
  vector[i] = 0.12345
}

w, err := client.Data().Creator().
  WithClassName("JeopardyQuestion").
  WithProperties(map[string]interface{}{
    "question": "This vector DB is OSS and supports automatic property type inference on import",
    "answer":   "Weaviate",
  }).
  WithID("12345678-e64f-5d94-90db-c8cfa3fc1234").
  Do(ctx)
```

```java title="Java" {8}
Map<String, Object> properties = new HashMap<>();
properties.put("question",
    "This vector DB is OSS and supports automatic property type inference on import");
properties.put("answer", "Weaviate");

var jeopardy = client.collections.use("JeopardyQuestion");
var uuid = jeopardy.data.insert(properties,
    meta -> meta.uuid("12345678-e64f-5d94-90db-c8cfa3fc1234")
).uuid();

System.out.println(uuid); // the return value is the object's UUID
```

```csharp title="C#" {8-9}
var jeopardy = client.Collections.Use("JeopardyQuestion");
var uuid = await jeopardy.Data.Insert(
    new
    {
        question = "This vector DB is OSS and supports automatic property type inference on import",
        answer = "Weaviate",
    },
    uuid: Guid.Parse("12345678-e64f-5d94-90db-c8cfa3fc1234")
);

Console.WriteLine(uuid); // the return value is the object's UUID
```
:::

## Generate deterministic IDs

You can generate an ID based on your data object.

:::callout{intent="info"}
Object IDs are not randomly generated. The same value always generates the same ID.\
Weaviate throws an error if you provide a duplicate ID. Use deterministic IDs to avoid inserting duplicate objects.
:::

:::code-group{sync="languages"}
```python title="Python" {1,11}
from weaviate.util import generate_uuid5  # Generate a deterministic ID

data_object = {
    "question": "This vector DB is OSS and supports automatic property type inference on import",
    "answer": "Weaviate",
}

jeopardy = client.collections.use("JeopardyQuestion")
uuid = jeopardy.data.insert(
    properties=data_object,
    uuid=generate_uuid5(data_object),
)
```

```typescript title="JavaScript/TypeScript" {1}
import { generateUuid5 } from 'weaviate-client';
```

```go title="Go"
// This feature is under development
```

```java title="Java" {1-2,11}
// In Java, you can generate a deterministic UUID from a string or bytes.
// This helper function uses UUID.nameUUIDFromBytes for this purpose.

Map<String, Object> dataObject = new HashMap<>();
dataObject.put("question",
    "This vector DB is OSS and supports automatic property type inference on import");
dataObject.put("answer", "Weaviate");

var jeopardy = client.collections.use("JeopardyQuestion");
var uuid = jeopardy.data.insert(dataObject,
    meta -> meta.uuid(generateUuid5(dataObject.toString()).toString())
).uuid();
```

```csharp title="C#" {1-2,14-15}
// In C#, you can generate a deterministic UUID from a string or bytes.
// This helper function creates a UUID v5 for this purpose.

var dataObject = new
{
    question = "This vector DB is OSS and supports automatic property type inference on import",
    answer = "Weaviate",
};
var dataObjectString = JsonSerializer.Serialize(dataObject);

var jeopardy = client.Collections.Use("JeopardyQuestion");
var uuid = await jeopardy.Data.Insert(
    dataObject,
    uuid: GenerateUuid5(dataObjectString)
);
```
:::

:::accordion{title="Additional information"}
To generate deterministic IDs, use one of these methods:

- `generate_uuid5` (Python)
- `generateUuid5` (TypeScript)
:::

## Create an object with cross-references

:::callout{intent="warning" title="Cross-references and query performance"}
Queries involving cross-references can be slower than queries that do not involve cross-references, especially at scale such as for multiple objects or complex queries.

At the first instance, we strongly encourage you to consider whether you can avoid using cross-references in your data schema. As a scalable AI database, Weaviate is well-placed to perform complex queries with vector, keyword and hybrid searches involving filters. You may benefit from rethinking your data schema to avoid cross-references where possible.

For example, instead of creating separate "Author" and "Book" collections with cross-references, consider embedding author information directly in Book objects and using searches and filters to find books by author characteristics.
:::

You can create an object with cross-references to other objects.

:::code-group{sync="languages"}
```python title="Python" {6}
questions = client.collections.use("JeopardyQuestion")

questions.data.insert(
    properties=properties,  # A dictionary with the properties of the object
    uuid=obj_uuid,  # The UUID of the object
    references={"hasCategory": category_uuid},  # e.g. {"hasCategory": "583876f3-e293-5b5b-9839-03f455f14575"}
)
```

```typescript title="JavaScript/TypeScript" {7-9}
const category = client.collections.use('JeopardyCategory')

const dataObject = {'name': 'Science'}

const response = await category.data.insert({
  properties: dataObject,
  references: {
    'hasCategory': categoryId  // e.g. {'hasCategory': '583876f3-e293-5b5b-9839-03f455f14575'}
  }
})

console.log('UUID: ', response)
```

```java title="Java" {5-6}
var questions = client.collections.use("JeopardyQuestion");

var result = questions.data.insert(properties, // A map with the properties of the object
    opt -> opt
        .reference("hasCategory", ObjectReference.uuids(categoryUuid)) // e.g. {"hasCategory":
// "583876f3-e293-5b5b-9839-03f455f14575"}
);
```

```csharp title="C#"
```
:::

:::callout{intent="tip" title="Additional information"}
See [How-to: Cross-references](../how-to-manage-collections/cross-references.md) for more on working with cross-references.
:::

## Create an object with `geoCoordinates`

:::callout{intent="note" title="Limitations"}
Currently, geo-coordinate filtering is limited to the nearest 800 results from the source location, which will be further reduced by any other filter conditions and search parameters.

If you plan on a densely populated dataset, consider using another strategy such as geo-hashing into a `text` datatype, and filtering further, such as with a `ContainsAny` filter.
:::

If you want to supply a [`geoCoordinates`](../reference-configuration/datatypes.md#geocoordinates) property, you need to specify the `latitude` and `longitude` as floating point decimal degrees:

:::code-group{sync="languages"}
```python title="Python"
publications = client.collections.use("Publication")

publications.data.insert(
    properties={
        "headquartersGeoLocation": {
            "latitude": 52.3932696,
            "longitude": 4.8374263
        }
    },
)
```

```js title="JavaScript/TypeScript"
const publication = client.collections.use('Publication')

uuid = await publication.data.insert({
  properties: {
    name: 'Elsevier',
    headquartersGeoLocation: {
      'latitude': 52.3932696,
      'longitude': 4.8374263,
    },
  },
  id: 'df48b9f6-ba48-470c-bf6a-57657cb07390'
})

console.log('UUID: ', uuid)
```

```go title="Go"
package main

import (
  "context"
  "fmt"

  "github.com/weaviate/weaviate-go-client/v5/weaviate"
)

func main() {
  cfg := weaviate.Config{
    Host:   "localhost:8080",
    Scheme: "http",
  }
  client, err := weaviate.NewClient(cfg)
  if err != nil {
    panic(err)
  }

  dataSchema := map[string]interface{}{
    "name": "Elsevier",
    "headquartersGeoLocation": map[string]float32{
      "latitude":  52.3932696,
      "longitude": 4.8374263,
    },
  }

  created, err := client.Data().Creator().
    WithClassName("Publication").
    WithID("df48b9f6-ba48-470c-bf6a-57657cb07390").
    WithProperties(dataSchema).
    Do(context.Background())

  if err != nil {
    panic(err)
  }
  fmt.Printf("%v", created)
}
```

```java title="Java"
var publications = client.collections.use("Publication");

var uuid = publications.data
    .insert(Map.of("headquartersGeoLocation",
        Map.of("latitude", 52.3932696, "longitude", 4.8374263)))
    .uuid();
```

```csharp title="C#"
var publications = client.Collections.Use("Publication");

var uuid = await publications.Data.Insert(
    new { headquartersGeoLocation = new GeoCoordinate(52.3932696f, 4.8374263f) }
);
```
:::

## Validate objects before creation

Before you create an object, you can [validate](/weaviate/api/rest#tag/objects/post/objects/validate) it against the collection definition.

:::code-group{sync="languages"}
```python title="Python"
# Validate is currently not supported with the Weaviate Python client v4
```

```typescript title="JavaScript/TypeScript"
// Validate is currently not supported with the Weaviate TypeScript client v3
```

```go title="Go"
err := client.Data().Validator().
  WithClassName("JeopardyQuestion").
  WithProperties(map[string]interface{}{
    "question":                          "This vector DB is OSS and supports automatic property type inference on import",
    "answer":                            "Weaviate",
    "thisPropShouldNotEndUpInTheSchema": -1,
  }).
  WithID("12345678-1234-1234-1234-123456789012").
  Do(ctx)
```

```java title="Java"
// Coming soon
```

```csharp title="C#"
// Coming soon
```
:::

## Multiple vector embeddings (named vectors)

Collections can have multiple [named vectors](../reference-configuration/collections.md#multiple-vector-embeddings-named-vectors).

The vectors in a collection can have their own configurations. Each vector space can set its own index, its own compression algorithm, and its own vectorizer. This means you can use different vectorization models, and apply different distance metrics, to the same object.

To work with named vectors, adjust your queries to specify a target vector for [vector search](../how-to-query-search/similarity.md#named-vectors) or [hybrid search](../how-to-query-search/hybrid.md#named-vectors) queries.

## Related pages

- [Connect to Weaviate](../connect-to-weaviate/index.md)
- [How-to: (Batch) Import items](import.md)
- [References: REST - /v1/objects](/weaviate/api/rest#tag/objects)

## Questions and feedback

Have a question or feedback? Here's how to reach us.

::::card-grid
:::card{title="Community Forum" href="https://forum.weaviate.io/c/support" icon="messages-square"}
Ask questions and connect with other developers on our **Community forum**.
:::

:::card{title="Support" href="/guides/support-overview" icon="life-buoy"}
Weaviate Cloud user or customer? Find the right channel on the **Support page**.
:::
::::

## Related pages

- [Agents](./agents-index.md)
- [AI-assisted Weaviate code generation](./ai-assisted-vibe-coding-index.md)
- [APIs](./apis-index.md)
- [Authorization and authentication](./authorization-and-authentication-index.md)
- [Benchmarks](./benchmarks-index.md)
- [Best practices](./best-practices-index.md)
- [Client libraries](./clients-index.md)
- [Client Libraries / SDKs](./client-libraries-index.md)
- [Cloud](./cloud-index.md)
- [Cloud account management](./cloud-account-management-index.md)

# Agent Instructions

This portal answers questions programmatically. To receive a synthesized,
source-cited answer instead of crawling page by page, append the `?ask=`
query parameter to any page URL on this site:

    /guides/quickstart?ask=how+do+I+authenticate

Optional parameters:

- `&goal=<what-you-are-trying-to-do>` steers the answer toward your
  objective (e.g. `&goal=write+a+python+client`).
- `&version=<label>` scopes the answer to a mounted version when the
  portal publishes more than one.

The response is `text/markdown`: the answer followed by a `# Sources` list
of the portal pages it was grounded in. Status codes are the contract:

- `200` — the answer; `402` — the portal owner’s plan or answer credits are
  exhausted (surface this to your operator; do NOT retry); `429` — you are
  rate-limited; back off for the `Retry-After` seconds; `503` — the answer
  lane is temporarily unavailable; fall back to crawling the `.md` pages.

For the full corpus map read `llms.txt` at the site root; for the tool
surface (search + page fetch as MCP tools) see `/mcp`.
