---
title: "Add Problem Json"
method: POST
path: "/problem/add_json"
---

# Add Problem Json

`POST /problem/add_json`

Adds a problem to the database based on its JSON definition.

Args:
    json_file (UploadFile): a file in JSON format describing the problem.
    user (Annotated[User, Depends): the usr for which the problem is added.
    session (Annotated[Session, Depends): the database session.

Raises:
    HTTPException: if the provided `json_file` is empty.
    HTTPException: if the content in the provided `json_file` is not in JSON format.__annotations__

Returns:
    ProblemInfo: a description of the added problem.

## 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.

## Other responses

- `422` — Validation Error

## Changes

- **2026-07-17** `c24fa4e23380` — 1 info
  - endpoint added
- **2025-05-20** `bbcc40488a72` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/industrial-optimization-group/apis/desdeo-fast-api/changes/problem/add_json/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)
