> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a new triple (fact) in the knowledge base.

> A triple represents a relationship between two entities in the form: (subject, predicate, object) - e.g., ('Socrates', 'is_a', 'Human') Request Body -…

A triple represents a relationship between two entities in the form:
(subject, predicate, object) - e.g., ('Socrates', 'is\_a', 'Human')
**Request Body**

* `subject_id`: ID of the subject entity (must exist)
* `predicate`: Relationship name (e.g., 'is\_a', 'has\_property')
* `object_id`: ID of the object entity (must exist)
* `confidence`: Optional confidence score (0.0-1.0, default: 1.0)
  **Errors**
* `400 Bad Request`: Invalid input or referenced entities don't exist
  Create a triple (relation) between entities.

**Required scope:** `write`

### Request body

`CreateTripleRequest`

<ParamField body="confidence" type="number (float)">
  Optional confidence score
</ParamField>

<ParamField body="object_id" type="string" required>
  Object entity ID
</ParamField>

<ParamField body="predicate" type="string" required>
  Predicate/relationship name
</ParamField>

<ParamField body="subject_id" type="string" required>
  Subject entity ID
</ParamField>

<ParamField body="valid_from" type="string">
  Optional RFC3339 start of validity interval.
</ParamField>

<ParamField body="valid_to" type="string">
  Optional RFC3339 end of validity interval (must be >= valid\_from).
</ParamField>

### Response

`TripleResponse`

<ResponseField name="confidence" type="number (float)" required />

<ResponseField name="object" type="string" required />

<ResponseField name="object_name" type="string" required />

<ResponseField name="predicate" type="string" required />

<ResponseField name="subject" type="string" required />

<ResponseField name="subject_name" type="string" required />

<ResponseField name="valid_from" type="string" />

<ResponseField name="valid_to" type="string" />

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `201` | Triple created successfully                        |
| `400` | Invalid input or referenced entities don't exist   |
| `401` | Unauthorized — missing or invalid credentials      |
| `402` | Tenant quota exceeded                              |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/triples' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "confidence": 1,
    "object_id": "string",
    "predicate": "string",
    "subject_id": "string",
    "valid_from": "string",
    "valid_to": "string"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "confidence": 1,
    "object": "string",
    "object_name": "string",
    "predicate": "string",
    "subject": "string",
    "subject_name": "string",
    "valid_from": "string",
    "valid_to": "string"
  }
  ```
</ResponseExample>
