API reference

Rules

Organization policies applied to every turn they reach.

List rules

GETapi.niucore.com/api/v1/rules

Scope: rules:read

The organization's rules visible to the user.

Query

levelstring

Filters by level.

companyarea

pageintegerdefaults to 1

Page number, starting at 1.

sizeintegerdefaults to 50

Items per page. Maximum 200.

curl -sS -X GET 'https://api.niucore.com/api/v1/rules?level=company' \
  -H "Authorization: Bearer $NIUCORE_ACCESS_TOKEN"
Response
{
  "status": "success",
  "message": "Operación exitosa",
  "message_code": "api_v1_ok",
  "data": [
    {
      "id": 58,
      "name": "No prometer plazos de entrega",
      "description": "Aplica a toda la empresa.",
      "instructions": "Nunca comprometas una fecha de entrega sin confirmarla con logística.",
      "icon": "shield",
      "level": "company",
      "area_ids": [],
      "is_active": true,
      "created_at": "2026-05-20T08:44:02Z"
    }
  ],
  "meta": {
    "request_id": "9f1c0a3e-7b2d-4f18-9a55-2c6e0d1b4a77",
    "page": 1,
    "size": 50,
    "total": 1
  }
}

Create a rule

POSTapi.niucore.com/api/v1/rules

Scope: rules:write

Creates a company-level or area-level rule. Returns 201.

Request body

namestringrequired

Up to 255 characters.

instructionsstringrequired

The instruction applied to every turn it reaches. Up to 4,000 characters. It can cite libraries, files, connectors and tools with {{type:id}} —not skills—: see Resource references.

descriptionstring

Description.

iconstring

Icon.

levelstringdefaults to company

Scope of the rule.

companyarea

area_idsinteger[]

Areas reached, with level: "area". They must be within the credential's scope.

Errors

  • 403api_v1_resource_policy_create_deniedThe credential is limited to specific resources (allowlist) and cannot create new ones of this type.
  • 422prompt_refs_invalidinstructions cites resources that do not exist, that the user cannot use, or that this type does not accept. data[0] groups them by category and nothing is saved. See Resource references.
  • 422prompt_text_too_longinstructions exceeds 4 000 characters.
curl -sS -X POST 'https://api.niucore.com/api/v1/rules' \
  -H "Authorization: Bearer $NIUCORE_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "No prometer plazos de entrega",
    "instructions": "Nunca comprometas una fecha de entrega sin confirmarla con logística.",
    "level": "company"
  }'
Response
{
  "status": "success",
  "message": "Operación exitosa",
  "message_code": "api_v1_ok",
  "data": {
    "id": 58,
    "name": "No prometer plazos de entrega",
    "description": "Aplica a toda la empresa.",
    "instructions": "Nunca comprometas una fecha de entrega sin confirmarla con logística.",
    "icon": "shield",
    "level": "company",
    "area_ids": [],
    "is_active": true,
    "created_at": "2026-05-20T08:44:02Z"
  },
  "meta": {
    "request_id": "9f1c0a3e-7b2d-4f18-9a55-2c6e0d1b4a77"
  }
}

Retrieve a rule

GETapi.niucore.com/api/v1/rules/{rule_id}

Scope: rules:read

Detail of one rule.

Path

rule_idintegerrequired

Identifier.

Errors

  • 404api_v1_not_foundIt does not exist, or it is outside the credential's scope. Both cases answer the same: a 403 would confirm the resource exists.
curl -sS -X GET 'https://api.niucore.com/api/v1/rules/58' \
  -H "Authorization: Bearer $NIUCORE_ACCESS_TOKEN"
Response
{
  "status": "success",
  "message": "Operación exitosa",
  "message_code": "api_v1_ok",
  "data": {
    "id": 58,
    "name": "No prometer plazos de entrega",
    "description": "Aplica a toda la empresa.",
    "instructions": "Nunca comprometas una fecha de entrega sin confirmarla con logística.",
    "icon": "shield",
    "level": "company",
    "area_ids": [],
    "is_active": true,
    "created_at": "2026-05-20T08:44:02Z"
  },
  "meta": {
    "request_id": "9f1c0a3e-7b2d-4f18-9a55-2c6e0d1b4a77"
  }
}

Update a rule

PATCHapi.niucore.com/api/v1/rules/{rule_id}

Scope: rules:write

Updates the fields sent.

Path

rule_idintegerrequired

Identifier.

Request body

namestring

New name.

instructionsstring

New instructions. If they change, all their {{type:id}} references are revalidated.

descriptionstring

Description.

iconstring

Icon.

levelstring

New level.

companyarea

is_activeboolean

Enables or disables the rule.

area_idsinteger[]

Replaces the areas reached.

Errors

  • 404api_v1_not_foundIt does not exist, or it is outside the credential's scope. Both cases answer the same: a 403 would confirm the resource exists.
  • 422prompt_refs_invalidinstructions cites resources that do not exist, that the user cannot use, or that this type does not accept. data[0] groups them by category and nothing is saved. See Resource references.
  • 422prompt_text_too_longinstructions exceeds 4 000 characters.
curl -sS -X PATCH 'https://api.niucore.com/api/v1/rules/58' \
  -H "Authorization: Bearer $NIUCORE_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "is_active": false
  }'
Response
{
  "status": "success",
  "message": "Operación exitosa",
  "message_code": "api_v1_ok",
  "data": {
    "id": 58,
    "name": "No prometer plazos de entrega",
    "description": "Aplica a toda la empresa.",
    "instructions": "Nunca comprometas una fecha de entrega sin confirmarla con logística.",
    "icon": "shield",
    "level": "company",
    "area_ids": [],
    "is_active": false,
    "created_at": "2026-05-20T08:44:02Z"
  },
  "meta": {
    "request_id": "9f1c0a3e-7b2d-4f18-9a55-2c6e0d1b4a77"
  }
}

Enable or disable

PATCHapi.niucore.com/api/v1/rules/{rule_id}/toggle

Scope: rules:write

Flips the active state.

Path

rule_idintegerrequired

Identifier.

Errors

  • 404api_v1_not_foundIt does not exist, or it is outside the credential's scope. Both cases answer the same: a 403 would confirm the resource exists.
curl -sS -X PATCH 'https://api.niucore.com/api/v1/rules/58/toggle' \
  -H "Authorization: Bearer $NIUCORE_ACCESS_TOKEN"
Response
{
  "status": "success",
  "message": "Operación exitosa",
  "message_code": "api_v1_ok",
  "data": {
    "id": 58,
    "name": "No prometer plazos de entrega",
    "description": "Aplica a toda la empresa.",
    "instructions": "Nunca comprometas una fecha de entrega sin confirmarla con logística.",
    "icon": "shield",
    "level": "company",
    "area_ids": [],
    "is_active": false,
    "created_at": "2026-05-20T08:44:02Z"
  },
  "meta": {
    "request_id": "9f1c0a3e-7b2d-4f18-9a55-2c6e0d1b4a77"
  }
}

Delete a rule

DELETEapi.niucore.com/api/v1/rules/{rule_id}

Scope: rules:write

Soft delete.

Path

rule_idintegerrequired

Identifier.

Errors

  • 404api_v1_not_foundIt does not exist, or it is outside the credential's scope. Both cases answer the same: a 403 would confirm the resource exists.
curl -sS -X DELETE 'https://api.niucore.com/api/v1/rules/58' \
  -H "Authorization: Bearer $NIUCORE_ACCESS_TOKEN"
Response
{
  "status": "success",
  "message": "Operación exitosa",
  "message_code": "api_v1_ok",
  "data": {
    "id": 58
  },
  "meta": {
    "request_id": "9f1c0a3e-7b2d-4f18-9a55-2c6e0d1b4a77"
  }
}