# Model Schema

This document describes the Model object schema returned by the globalMOO API.

## Structure

```json
{
  "id": 123,                                     // Unique identifier
  "createdAt": "2025-01-31T10:00:00.000Z",      // Creation timestamp
  "updatedAt": "2025-01-31T10:00:00.000Z",      // Last update timestamp
  "disabledAt": null,                           // Optional disable timestamp
  "name": "Production Optimization",             // Model name
  "description": "Optimization model for production planning", // Optional description
  "projects": [                                  // Associated projects
    {
      "id": 456,
      "createdAt": "2025-01-31T10:00:00.000Z",
      "updatedAt": "2025-01-31T10:00:00.000Z",
      "disabledAt": null,
      "name": "Q1 Planning",
      "description": "First quarter production planning",
      "configuration": {
        "parameters": {
          "max_iterations": 1000,
          "convergence_threshold": 0.001
        }
      }
    }
  ]
}
```

## Fields

| Field         | Type                                                                                             | Description                                           |
| ------------- | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |
| `id`          | integer                                                                                          | Unique identifier for the model                       |
| `createdAt`   | string (ISO 8601)                                                                                | Timestamp when the model was created                  |
| `updatedAt`   | string (ISO 8601)                                                                                | Timestamp when the model was last updated             |
| `disabledAt`  | string (ISO 8601) or null                                                                        | Timestamp when the model was disabled, null if active |
| `name`        | string                                                                                           | Name of the model                                     |
| `description` | string or null                                                                                   | Description of the model, null if not provided        |
| `projects`    | array of [Project](https://globalmoo.gitbook.io/globalmoo-documentation/schemas/project) objects | List of projects associated with this model           |

## SDK Representations

### JavaScript SDK

In the JavaScript SDK, the Model object uses snake\_case naming for some fields, translating from the API's camelCase:

```javascript
{
  id: 123,
  created_at: Date("2025-01-31T10:00:00.000Z"),  // Converted to Date object
  updated_at: Date("2025-01-31T10:00:00.000Z"),  // Converted to Date object
  disabled_at: null,
  name: "Production Optimization",
  description: "Optimization model for production planning",
  projects: [
    // Project objects are also instantiated with their constructor
    Project({
      id: 456,
      // ... other project properties
    })
  ]
}
```

### Python SDK

The Python SDK also uses snake\_case naming and converts timestamps to datetime objects:

```python
Model(
  id=123,
  created_at=datetime(2025, 1, 31, 10, 0, 0),    # Converted to datetime object
  updated_at=datetime(2025, 1, 31, 10, 0, 0),    # Converted to datetime object
  disabled_at=None,
  name="Production Optimization",
  description="Optimization model for production planning",
  projects=[
    # List of Project objects
    Project(
      id=456,
      # ... other project properties
    )
  ]
)
```

### PHP SDK

The PHP SDK maintains camelCase naming to match the API and converts timestamps to DateTimeImmutable objects:

```php
Model(
  id: 123,
  createdAt: DateTimeImmutable("2025-01-31T10:00:00.000Z"),  // DateTimeImmutable object
  updatedAt: DateTimeImmutable("2025-01-31T10:00:00.000Z"),  // DateTimeImmutable object
  disabledAt: null,
  name: "Production Optimization",
  description: "Optimization model for production planning",
  projects: [
    // Array of Project objects
    Project(
      id: 456,
      // ... other project properties
    )
  ]
)
```

## Examples

### Simple Model

```json
{
  "id": 123,
  "createdAt": "2025-01-31T10:00:00.000Z",
  "updatedAt": "2025-01-31T10:00:00.000Z",
  "disabledAt": null,
  "name": "Basic Optimization",
  "description": "A simple optimization model",
  "projects": []
}
```

### Model with Projects

```json
{
  "id": 456,
  "createdAt": "2025-01-15T10:00:00.000Z",
  "updatedAt": "2025-02-01T14:30:00.000Z",
  "disabledAt": null,
  "name": "Advanced Production Planning",
  "description": "Multi-stage production optimization",
  "projects": [
    {
      "id": 789,
      "createdAt": "2025-01-15T10:30:00.000Z",
      "updatedAt": "2025-01-15T10:30:00.000Z",
      "disabledAt": null,
      "name": "Factory A Optimization",
      "description": "Production planning for Factory A",
      "configuration": {
        "parameters": {
          "max_iterations": 2000,
          "convergence_threshold": 0.0005
        }
      }
    },
    {
      "id": 790,
      "createdAt": "2025-01-20T11:15:00.000Z",
      "updatedAt": "2025-01-20T11:15:00.000Z",
      "disabledAt": null,
      "name": "Factory B Optimization",
      "description": "Production planning for Factory B",
      "configuration": {
        "parameters": {
          "max_iterations": 1500,
          "convergence_threshold": 0.001
        }
      }
    }
  ]
}
```

## Related Endpoints

* [Model Endpoints](https://globalmoo.gitbook.io/globalmoo-documentation/endpoints/models/index)
* [Create Model](https://globalmoo.gitbook.io/globalmoo-documentation/endpoints/models/create)
* [List Models](https://globalmoo.gitbook.io/globalmoo-documentation/endpoints/models/list)
