# Codes

Here, you'll find key exports for managing codes. These exports allow you to create, update and delete codes as needed.

***

## Type

```typescript
type Code = {
    id: number,
    name: string,
    description: string,
    code: string,
    createdAt: string
}
```

## Exports

### Search for a code

```lua
exports['redutzu-mdt']:SearchCode(id: number) // CodeType | null
```

### Create a new code

```lua
exports['redutzu-mdt']:CreateCode({
  name = 'Code name',
  description = 'Code description',
  code = '1-101'
}) -- number (id)
```

### Update a code

```lua
-- It returns a boolean (if it was successfully updated)
exports['redutzu-mdt']:UpdateCode(id, { name = 'New code name' }) -- boolean
```

### Delete a code

```lua
-- It returns a boolean (if it was successfully deleted)
exports['redutzu-mdt']:DeleteCode(id: number) // boolean
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redutzu.com/resources/redutzu-mdt/exports-events/server-exports/codes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
