---
title: "Add Problem"
method: POST
path: "/problem/add"
---

# Add Problem

`POST /problem/add`

Add a newly defined problem to the database.

Args:
    request (Problem): the JSON representation of the problem.
    user (Annotated[User, Depends): the current user.
    session (Annotated[Session, Depends): the database session.

Note:
    Users with the role 'guest' may not add new problems.

Raises:
    HTTPException: when any issue with defining the problem arises.

Returns:
    ProblemInfo: the information about the problem added.

## Response `200`

Successful Response

- ProblemInfo — Problem info request return data.
  - `name` string, required
  - `description` string, required
  - `is_convex` boolean, nullable, required
  - `is_linear` boolean, nullable, required
  - `is_twice_differentiable` boolean, nullable, required
  - `scenario_keys` string[], nullable, required
  - `variable_domain` 'continuous' | 'binary' | 'integer' | 'mixed', required — An enumerator for the possible variable type domains of a problem.
  - `id` integer, required
  - `user_id` integer, required
  - `constants` ConstantDB[], nullable, required
    - `name` string, required — Descriptive name of the constant. This can be used in UI and visualizations. Example: 'maximum cost'.
    - `symbol` string, required — Symbol to represent the constant. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'c_1'.
    - `value` number, required — The value of the constant.
    - `id` integer, nullable
    - `problem_id` integer, nullable
  - `tensor_constants` TensorConstantDB[], nullable, required
    - `values` union, required
      - Tensor[]
      - union[]
        - union
          - number
          - integer
          - boolean
      - number
      - integer
      - boolean
      - 'List'
    - `shape` integer[], required
    - `name` string, required — Descriptive name of the tensor representing the values. E.g., 'distances'
    - `symbol` string, required — Symbol to represent the constant. This will be used in the rest of the problem definition. Notice that the elements of the tensor will be represented with the symbol followed by indices. E.g., the first element of the third element of a 2-dimensional tensor, is represented by 'x_1_3', where 'x' is the symbol given to the TensorVariable. Note that indexing starts from 1.
    - `id` integer, nullable
    - `problem_id` integer, nullable
  - `variables` VariableDB[], nullable, required
    - `name` string, required — Descriptive name of the variable. This can be used in UI and visualizations. Example: 'velocity'.
    - `symbol` string, required — Symbol to represent the variable. This will be used in the rest of the problem definition. It may also be used in UIs and visualizations. Example: 'v_1'.
    - `variable_type` 'real' | 'integer' | 'binary', required — An enumerator for possible variable types.
    - `lowerbound` number, nullable — Lower bound of the variable.
    - `upperbound` number, nullable — Upper bound of the variable.
    - `initial_value` number, nullable — Initial value of the variable. This is optional.
    - `id` integer, nullable
    - `problem_id` integer, nullable
  - `tensor_variables` TensorVariableDB[], nullable, required
    - `initial_values` union, required
      - Tensor[]
      - union[]
        - union
          - number
          - integer
          - boolean
      - number
      - integer
      - boolean
      - 'List'
    - `lowerbounds` union, required
      - Tensor[]
      - union[]
        - union
          - number
          - integer
          - boolean
      - number
      - integer
      - boolean
      - 'List'
    - `upperbounds` union, required
      - Tensor[]
      - union[]
        - union
          - number
          - integer
          - boolean
      - number
      - integer
      - boolean
      - 'List'
    - `shape` integer[], required
    - `name` string, required — Descriptive name of the variable. This can be used in UI and visualizations. Example: 'velocity'.
    - `symbol` string, required — Symbol to represent the variable. This will be used in the rest of the problem definition. Notice that the elements of the tensor will be represented with the symbol followed by indices. E.g., the first element of the third element of a 2-dimensional tensor, is represented by 'x_1_3', where 'x' is the symbol given to the TensorVariable. Note that indexing starts from 1.
    - `variable_type` 'real' | 'integer' | 'binary', required — An enumerator for possible variable types.
    - `id` integer, nullable
    - `problem_id` integer, nullable
  - `objectives` ObjectiveDB[], required — unresolved $ref
  - `constraints` ConstraintDB[], nullable, required — unresolved $ref
  - `scalarization_funcs` ScalarizationFunctionDB[], nullable, required
    - `func` unknown[], required
      - unknown
    - `scenario_keys` string[], required
    - `name` string, required — Name of the scalarization function.
    - `symbol` string, nullable — Optional symbol to represent the scalarization function. This may be used in UIs and visualizations.
    - `is_linear` boolean — Whether the function expression is linear or not. Defaults to `False`.
    - `is_convex` boolean — Whether the function expression is convex or not (non-convex). Defaults to `False`.
    - `is_twice_differentiable` boolean — Whether the function expression is twice differentiable or not. Defaults to `False`
    - `id` integer, nullable
    - `problem_id` integer, nullable
  - `extra_funcs` ExtraFunctionDB[], nullable, required — unresolved $ref
  - `discrete_representation` DiscreteRepresentationDB, required — The SQLModel equivalent to `DiscreteRepresentation`.
    - `non_dominated` boolean
    - `variable_values` object, required
    - `objective_values` object, required
    - `id` integer, nullable
    - `problem_id` integer, nullable
  - `simulators` SimulatorDB[], nullable, required — unresolved $ref
  - `problem_metadata` ProblemMetaDataPublic, required — Response model for ProblemMetaData.
    - `problem_id` integer, required
    - `forest_metadata` ForestProblemMetaData[], nullable, required
      - `id` integer, nullable
      - `metadata_id` integer, nullable
      - `metadata_type` string
      - `map_json` string, required
      - `schedule_dict` object, required
      - `years` string[], required
      - `stand_id_field` string, required
      - `stand_descriptor` object, nullable
      - `compensation` number, nullable
    - `representative_nd_metadata` RepresentativeNonDominatedSolutions[], nullable, required
      - `id` integer, nullable
      - `metadata_id` integer, nullable
      - `metadata_type` string
      - `name` string, required — The name of the representative set.
      - `description` string, nullable — A description of the representative set. Optional.
      - `solution_data` object, required — The non-dominated solutions. It is assumed that columns exist for each variable and objective function. For functions, the `_min` variant should be present, and any tensor variables should be unrolled.
      - `ideal` object, required — The ideal objective function values of the representative set.
      - `nadir` object, required — The nadir objective function values of the representative set.

## Changes

- **2026-07-17** `c24fa4e23380` — 3 breaking, 13 info
  - removed the request body
  - the response property `simulators/anyOf[subschema #1]/items/file` became optional for the status `200`
  - response property `simulators/anyOf[subschema #1]/items/file` list-of-types was widened by adding types `null` to media type `application/json` of response `200`
  - the endpoint scheme security `APIKeyCookie` was added to the API
  - …12 more
- **2025-05-20** `bbcc40488a72` — 2 breaking, 1 warning, 13 info
  - added required request body
  - removed the required property `problem_metadata` from the response with the `200` status
  - removed the optional property `simulators/anyOf[subschema #1]/items/url` from the response with the `200` status
  - the endpoint scheme security `APIKeyCookie` was removed from the API
  - …12 more

[Change history](https://skmtc.dev/industrial-optimization-group/apis/desdeo-fast-api/changes/problem/add/post.md)

---

[API](https://skmtc.dev/industrial-optimization-group/apis/desdeo-fast-api.md) · [All operations](https://skmtc.dev/industrial-optimization-group/apis/desdeo-fast-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/industrial-optimization-group/desdeo-fast-api/revisions/c24fa4e23380/schema)
