Skip to main content

Create objects

LICENSE Weaviate on Stackoverflow badge Weaviate issues on GitHub badge Weaviate version badge Weaviate total Docker pulls badge Go Report Card


This page shows you how to create individual objects in Weaviate.

To create multiple objects, it's best to use batch operations.


To create an object, specify:

  • The object data to be added, and
  • The target class.

For classes where multi-tenancy is enabled, you will also need to specify the tenant name when creating objects. See Manage data: multi-tenancy operations for details on how.

Object data vs class definition

Compared to the class definition, the object data:

  • Can omit defined properties.
  • Can include new properties.

Any new properties will be added to the class definition during object creation with auto-schema.


This example shows how to create an object in the JeopardyQuestion class, with:

  • An existing property (question),
  • A new property (somePropNotInTheSchema), and
  • Omits an existing property (answer).
uuid = client.data_object.create({
'question': 'This vector DB is OSS & supports automatic property type inference on import',
# 'answer': 'Weaviate', # schema properties can be omitted
'somePropNotInTheSchema': 123, # will be automatically added as a number property
}, 'JeopardyQuestion')

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

Optional parameters

Optionally, you can specify an id or a vector.


You can optionally specify an ID in UUID format. Otherwise, Weaviate will generate a random UUID.


You can optionally specify a vector to represent each object. Otherwise, Weaviate will follow the relevant vectorizer setting.


uuid = client.data_object.create(
'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

Preventing duplicates

In Weaviate, the only unique field is the id. If you try to create an object with an existing id, Weaviate will throw an error. (In batch imports, Weaviate will overwrite the object if one exists.)

To prevent duplicates, we suggest:

  • Using a deterministic ID generation method, and
  • Checking if an object exists before creating it.

Generate deterministic ID

You can do so with the generate_uuid5 function in the Python client, or the generateUuid5 function in the TypeScript client.


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',
uuid = client.data_object.create(

Check if an object exists

You can check if an object exists given its id.

IDs unique to each class and tenants

Classes and tenants each work like namespaces. So, it is possible to have the same id in different classes and/or tenants.

Validating before creation

You can validate an object against the class definition before creating it.

This will confirm:

  • Whether the creation of an object will succeed, and
  • That it doesn't have any extra properties vs. the schema.
result = client.data_object.validate(
'question': 'This vector DB is open-source and supports auto-schema',
'answer': 'Weaviate',
'thisPropShouldNotEndUpInTheSchema': -1,

# "invalid object: no such prop with name 'thisPropShouldNotEndUpInTheSchema' found..."
print(json.dumps(result, indent=2))

More Resources

For additional information, try these sources.

  1. Frequently Asked Questions
  2. Weaviate Community Forum
  3. Knowledge base of old issues
  4. Stackoverflow
  5. Weaviate slack channel