> ## Documentation Index
> Fetch the complete documentation index at: https://edgeful.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit Optimizer Job

> Queue a bounded optimization. Reuse request_id and settings after an uncertain response.

Requires write permission. Limits across all your keys and connections: one admission per 10 seconds,
60 per rolling hour and 300 per rolling day. Accepted failures/cancellations consume quota.
Identical retries return the original job. Changed settings conflict. Poll every ten seconds or resume later.



## OpenAPI

````yaml /openapi-public.json post /v1/optimizer/jobs
openapi: 3.1.0
info:
  title: Edgeful API
  description: >-
    Public API reference for Edgeful market analysis. The bearer token is your
    Edgeful API key. Reports support the docs playground. Report responses
    include row-level output in `detailed` only when your plan includes
    row-level detail.
  version: 1.0.0
servers:
  - url: https://api.edgeful.com
    description: Production
security:
  - BearerAuth: []
tags:
  - name: reports
  - name: discovery
  - name: live data
  - name: settings
  - name: custom reports
  - name: optimizer
paths:
  /v1/optimizer/jobs:
    post:
      tags:
        - optimizer
      summary: Submit Optimizer Job
      description: >-
        Queue a bounded optimization. Reuse request_id and settings after an
        uncertain response.


        Requires write permission. Limits across all your keys and connections:
        one admission per 10 seconds,

        60 per rolling hour and 300 per rolling day. Accepted
        failures/cancellations consume quota.

        Identical retries return the original job. Changed settings conflict.
        Poll every ten seconds or resume later.
      operationId: submit_optimizer_job_v1_optimizer_jobs_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExternalOptimizerRequest'
        required: true
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OptimizerJob'
        '401':
          description: Missing, invalid or revoked API key.
        '403':
          description: >-
            Requires active All Access and, for mutations, credential write
            permission.
        '404':
          description: Record or job is missing or belongs to another member.
        '409':
          description: >-
            Active job: Retry-After is present; retry the same request_id later.
            Accepted request_id with different settings: no Retry-After; use a
            new ID.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
        '413':
          description: Request body exceeds 16 KiB or snapshot exceeds 8 KiB.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Shared member optimizer budget exhausted. Follow Retry-After.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
        '503':
          description: >-
            Capacity or admission controls unavailable. Follow Retry-After;
            reuse request_id.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: >-
            # Requires jq and uuidgen. Keep optimizer-request.json for retries.

            export EDGEFUL_API_KEY="<api-key>"

            curl --fail-with-body -sS
            "https://api.edgeful.com/v1/optimizer/options?algo=orb"   -H
            "Authorization: Bearer $EDGEFUL_API_KEY" > optimizer-options.json

            jq --arg id "$(uuidgen)" '{request_id: $id, request_snapshot:
            .request_template}'   optimizer-options.json >
            optimizer-request.json

            curl --fail-with-body -sS -X POST
            "https://api.edgeful.com/v1/optimizer/jobs"   -H "Authorization:
            Bearer $EDGEFUL_API_KEY" -H "Content-Type: application/json"  
            --data-binary @optimizer-request.json
        - lang: python
          label: Python
          source: >-
            import json

            import os

            from pathlib import Path

            from uuid import uuid4

            import requests


            headers = {"Authorization": f"Bearer
            {os.environ['EDGEFUL_API_KEY']}"}

            options =
            requests.get("https://api.edgeful.com/v1/optimizer/options",
            headers=headers, timeout=15)

            options.raise_for_status()

            body = {"request_id": str(uuid4()), "request_snapshot":
            options.json()["request_template"]}

            # Retain the exact body; resend it after an uncertain response.

            Path("optimizer-request.json").write_text(json.dumps(body))

            response =
            requests.post("https://api.edgeful.com/v1/optimizer/jobs",
            headers=headers, json=body, timeout=15)

            response.raise_for_status()

            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >-
            // Node.js 20+. Keep optimizer-request.json for retries.

            import { randomUUID } from "node:crypto";

            import { writeFile } from "node:fs/promises";

            const headers = { Authorization: `Bearer
            ${process.env.EDGEFUL_API_KEY}` };

            const options = await
            fetch("https://api.edgeful.com/v1/optimizer/options", { headers });

            if (!options.ok) throw new Error(await options.text());

            const body = { request_id: randomUUID(), request_snapshot: (await
            options.json()).request_template };

            await writeFile("optimizer-request.json", JSON.stringify(body));

            const response = await
            fetch("https://api.edgeful.com/v1/optimizer/jobs", {
              method: "POST", headers: { ...headers, "Content-Type": "application/json" },
              body: JSON.stringify(body),
            });

            if (!response.ok) throw new Error(await response.text());

            console.log(await response.json());
components:
  schemas:
    ExternalOptimizerRequest:
      properties:
        request_id:
          type: string
          format: uuid
          title: Request Id
        request_snapshot:
          $ref: '#/components/schemas/OptimizerV1RequestSnapshot'
      additionalProperties: false
      type: object
      required:
        - request_id
        - request_snapshot
      title: ExternalOptimizerRequest
    OptimizerJob:
      properties:
        job_id:
          type: string
          title: Job Id
        request_id:
          type: string
          title: Request Id
        origin:
          type: string
          enum:
            - app
            - external
          title: Origin
        status:
          type: string
          enum:
            - queued
            - running
            - cancel_requested
            - succeeded
            - failed
            - cancelled
          title: Status
        run_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Run Id
        progress:
          additionalProperties:
            $ref: '#/components/schemas/JsonValue'
          type: object
          title: Progress
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        failure_kind:
          anyOf:
            - type: string
            - type: 'null'
          title: Failure Kind
        created_at:
          type: string
          title: Created At
        deadline_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Deadline At
        payload_expired:
          type: boolean
          title: Payload Expired
        result_expired:
          type: boolean
          title: Result Expired
        poll_after_seconds:
          anyOf:
            - type: integer
            - type: 'null'
          title: Poll After Seconds
      type: object
      required:
        - job_id
        - request_id
        - origin
        - status
        - run_id
        - progress
        - error
        - failure_kind
        - created_at
        - deadline_at
        - payload_expired
        - result_expired
        - poll_after_seconds
      title: OptimizerJob
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    OptimizerV1RequestSnapshot:
      properties:
        schemaVersion:
          type: string
          const: optimizer.v1
          title: Schemaversion
          default: optimizer.v1
        settings:
          $ref: '#/components/schemas/OptimizerRunSettingsSnapshot'
      additionalProperties: false
      type: object
      required:
        - settings
      title: OptimizerV1RequestSnapshot
    JsonValue: {}
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    OptimizerRunSettingsSnapshot:
      properties:
        ticker:
          type: string
          maxLength: 16
          minLength: 1
          title: Ticker
        algo:
          type: string
          enum:
            - orb
            - orb-2tp
            - orb-breakeven
            - ib
            - ib-breakeven
            - engulfing
            - engulfing-2tp
          title: Algo
        variant:
          $ref: '#/components/schemas/OptimizerStrategyVariant'
        durations:
          items:
            type: number
          type: array
          minItems: 1
          title: Durations
        selectedChartTimeframes:
          items:
            type: string
            enum:
              - 1m
              - 2m
              - 3m
              - 4m
              - 5m
              - 10m
              - 15m
              - 30m
          type: array
          maxItems: 8
          minItems: 1
          title: Selectedcharttimeframes
        dateRange:
          anyOf:
            - type: string
              enum:
                - 3M
                - 6M
                - 1Y
                - 2Y
            - $ref: '#/components/schemas/OptimizerCustomDateRange'
          title: Daterange
        sessionRange:
          type: string
          pattern: ^\d{4}-\d{4}$
          title: Sessionrange
        timezone:
          type: string
          title: Timezone
          default: America/New_York
        sweepRanges:
          $ref: '#/components/schemas/OptimizerSweepRanges'
        constraints:
          $ref: '#/components/schemas/OptimizerConstraints'
        validation:
          $ref: '#/components/schemas/OptimizerValidationConfig'
        contracts:
          type: integer
          minimum: 1
          title: Contracts
        entryCutoffSweep:
          $ref: '#/components/schemas/OptimizerEntryCutoffSweep'
        entryCutoffTime:
          anyOf:
            - type: string
            - type: 'null'
          title: Entrycutofftime
        ibCancelOnTpHit:
          type: boolean
          title: Ibcancelontphit
          default: false
      additionalProperties: false
      type: object
      required:
        - ticker
        - algo
        - variant
        - durations
        - selectedChartTimeframes
        - dateRange
        - sessionRange
        - sweepRanges
        - constraints
        - validation
        - contracts
      title: OptimizerRunSettingsSnapshot
    OptimizerStrategyVariant:
      properties:
        enable2ndTP:
          type: boolean
          title: Enable2Ndtp
        enableBreakevenStop:
          type: boolean
          title: Enablebreakevenstop
      additionalProperties: false
      type: object
      required:
        - enable2ndTP
        - enableBreakevenStop
      title: OptimizerStrategyVariant
    OptimizerCustomDateRange:
      properties:
        startDate:
          type: string
          format: date
          title: Startdate
        endDate:
          type: string
          format: date
          title: Enddate
      additionalProperties: false
      type: object
      required:
        - startDate
        - endDate
      title: OptimizerCustomDateRange
    OptimizerSweepRanges:
      properties:
        profitTarget:
          $ref: '#/components/schemas/OptimizerSweepRange'
        stopLoss:
          $ref: '#/components/schemas/OptimizerSweepRange'
        minOrbSize:
          $ref: '#/components/schemas/OptimizerSweepRange'
        maxOrbSize:
          $ref: '#/components/schemas/OptimizerSweepRange'
        dollarRisk:
          $ref: '#/components/schemas/OptimizerSweepRange'
        directions:
          items:
            type: string
            enum:
              - long only
              - short only
              - both
          type: array
          maxItems: 3
          minItems: 1
          title: Directions
        weekdays:
          items:
            type: string
            enum:
              - monday
              - tuesday
              - wednesday
              - thursday
              - friday
              - sunday
          type: array
          maxItems: 6
          minItems: 1
          title: Weekdays
        takeProfit2:
          $ref: '#/components/schemas/OptimizerSweepRange'
        moveStopTrigger:
          $ref: '#/components/schemas/OptimizerSweepRange'
        moveStopTarget:
          $ref: '#/components/schemas/OptimizerSweepRange'
        ibEntryLvl:
          $ref: '#/components/schemas/OptimizerSweepRange'
        ibStopLvl:
          $ref: '#/components/schemas/OptimizerSweepRange'
        ibTp1:
          $ref: '#/components/schemas/OptimizerSweepRange'
        ibTp2:
          $ref: '#/components/schemas/OptimizerSweepRange'
        gapTargetFill:
          anyOf:
            - $ref: '#/components/schemas/OptimizerSweepRange'
            - type: 'null'
        gapRiskRatio:
          anyOf:
            - $ref: '#/components/schemas/OptimizerSweepRange'
            - type: 'null'
        gapMinSize:
          anyOf:
            - $ref: '#/components/schemas/OptimizerSweepRange'
            - type: 'null'
        gapMaxSize:
          anyOf:
            - $ref: '#/components/schemas/OptimizerSweepRange'
            - type: 'null'
        engTp:
          $ref: '#/components/schemas/OptimizerSweepRange'
        engSl:
          $ref: '#/components/schemas/OptimizerSweepRange'
        engMinSize:
          $ref: '#/components/schemas/OptimizerSweepRange'
        engMaxSize:
          $ref: '#/components/schemas/OptimizerSweepRange'
      additionalProperties: false
      type: object
      required:
        - profitTarget
        - stopLoss
        - minOrbSize
        - maxOrbSize
        - dollarRisk
        - directions
        - takeProfit2
        - moveStopTrigger
        - moveStopTarget
        - ibEntryLvl
        - ibStopLvl
        - ibTp1
        - ibTp2
        - engTp
        - engSl
        - engMinSize
        - engMaxSize
      title: OptimizerSweepRanges
    OptimizerConstraints:
      properties:
        minWinRate:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        minProfitFactor:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxDrawdown:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxDrawdownProfitRatio:
          anyOf:
            - $ref: '#/components/schemas/OptimizerConstraintValue'
            - type: 'null'
        minTrades:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        minAvgReturnPerTrade:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxConsecutiveLosses:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxWinRate:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxProfitFactor:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxOosWinRateDrop:
          $ref: '#/components/schemas/OptimizerConstraintValue'
        maxOosProfitFactorDrop:
          $ref: '#/components/schemas/OptimizerConstraintValue'
      additionalProperties: false
      type: object
      required:
        - minWinRate
        - minProfitFactor
        - maxDrawdown
        - minTrades
        - minAvgReturnPerTrade
        - maxConsecutiveLosses
        - maxWinRate
        - maxProfitFactor
        - maxOosWinRateDrop
        - maxOosProfitFactorDrop
      title: OptimizerConstraints
    OptimizerValidationConfig:
      properties:
        mode:
          type: string
          enum:
            - none
            - holdout
          title: Mode
        holdoutTrainRatio:
          type: number
          maximum: 0.9
          minimum: 0.5
          title: Holdouttrainratio
      additionalProperties: false
      type: object
      required:
        - mode
        - holdoutTrainRatio
      title: OptimizerValidationConfig
    OptimizerEntryCutoffSweep:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: false
        start:
          type: string
          title: Start
          default: '12:00'
        end:
          type: string
          title: End
          default: '12:00'
        step:
          type: string
          enum:
            - 15m
            - 30m
          title: Step
          default: 30m
      additionalProperties: false
      type: object
      title: OptimizerEntryCutoffSweep
    OptimizerSweepRange:
      properties:
        min:
          type: number
          title: Min
        max:
          type: number
          title: Max
        step:
          type: number
          exclusiveMinimum: 0
          title: Step
      additionalProperties: false
      type: object
      required:
        - min
        - max
        - step
      title: OptimizerSweepRange
    OptimizerConstraintValue:
      properties:
        enabled:
          type: boolean
          title: Enabled
        value:
          type: number
          title: Value
      additionalProperties: false
      type: object
      required:
        - enabled
        - value
      title: OptimizerConstraintValue
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Send your Edgeful API key in the Authorization header as `Bearer
        <api-key>` (for example, `Bearer ef_live_<random>`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.