{
  "openapi": "3.0.1",
  "info": {
    "title": "Nyckel v1 API",
    "version": "v1"
  },
  "paths": {
    "/v1/functions/{functionId}/fields": {
      "get": {
        "tags": [
          "Fields"
        ],
        "summary": "List fields",
        "operationId": "ListFields",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "description": "The zero-based index of the first result to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "The number of results to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Field"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Field"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Field"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Fields"
        ],
        "summary": "Create field",
        "operationId": "PostField",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableField"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableField"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WritableField"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              }
            }
          }
        }
      }
    },
    "/v1/functions/{functionId}/fields/{fieldId}": {
      "get": {
        "tags": [
          "Fields"
        ],
        "summary": "Get field",
        "operationId": "GetField",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Fields"
        ],
        "summary": "Update field",
        "operationId": "PutField",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableField"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableField"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WritableField"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Field"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Fields"
        ],
        "summary": "Delete field",
        "operationId": "DeleteField",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions/{functionId}/invoke": {
      "post": {
        "tags": [
          "Invoke"
        ],
        "summary": "Execute InvokeFunction",
        "operationId": "InvokeFunction",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "description":"The ID of the function to invoke",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "labelCount",
            "in": "query",
            "description": "The number of labels to return in the response",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeMetadata",
            "in": "query",
            "description": "Whether to include metadata in the response",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "modelId",
            "in": "query",
            "description": "The ID of the model to use",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "capture",
            "in": "query",
            "description": "Whether to capture the invocation for later review",
            "schema": {
              "type": "boolean",
              "default": true
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "description": "The externalId of the Sample",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvokeInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoke succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionOutput"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/functions/{functionId}/labels": {
      "get": {
        "tags": [
          "Labels"
        ],
        "summary": "List labels",
        "operationId": "ListLabels",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "description": "The zero-based index of the first result to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "The number of results to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Label"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Label"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Label"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Labels"
        ],
        "summary": "Create label",
        "operationId": "PostLabel",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableLabel"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableLabel"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WritableLabel"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              }
            }
          }
        }
      }
    },
    "/v1/functions/{functionId}/labels/{labelId}": {
      "get": {
        "tags": [
          "Labels"
        ],
        "summary": "Get label",
        "operationId": "GetLabel",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "labelId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Labels"
        ],
        "summary": "Update label",
        "operationId": "PutLabel",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "labelId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableLabel"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableLabel"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WritableLabel"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Label"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Labels"
        ],
        "summary": "Delete label",
        "operationId": "DeleteLabel",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "labelId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions/{functionId}/samples": {
      "get": {
        "tags": [
          "Samples"
        ],
        "summary": "List samples",
        "operationId": "ListSamples",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "description": "The externalId of the Sample",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "description": "The zero-based index of the first result to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "The number of results to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "annotated",
            "in": "query",
            "description": "Whether the sample is annotated",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "predicted",
            "in": "query",
            "description": "Whether the sample is predicted",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "annotationLabelId",
            "in": "query",
            "description": "The label id for the annotation",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "predictionLabelId",
            "in": "query",
            "description": "The label id for the prediction",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "predictionAndAnnotationAgree",
            "in": "query",
            "description": "Whether the annotation and the prediction agrees",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "captureReason",
            "in": "query",
            "description": "The capture reason of the sample",
            "schema": {
              "$ref": "#/components/schemas/CaptureReason"
            }
          },
          {
            "name": "origin",
            "in": "query",
            "description": "The origin of the sample (e.g. `InvokeCapture`)",
            "schema": {
              "$ref": "#/components/schemas/SampleOrigin"
            }
          },
          {
            "name": "searchText",
            "in": "query",
            "description": "Text that should be present in the sample data",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleIds",
            "in": "query",
            "description": "The list of sample ids to return",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "sampleSetId",
            "in": "query",
            "description": "The sample set that the returned samples must belong to",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inTrainSet",
            "in": "query",
            "description": "Whether the returned samples must be in the training set",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "createdBefore",
            "in": "query",
            "description": "Date on or before which the sample was created",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdAfter",
            "in": "query",
            "description": "Date on or after which the sample was created",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "How the Samples are sorted for paging and returning",
            "schema": {
              "$ref": "#/components/schemas/SampleSortBy"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "description": "The order of sorting samples for paging and returning. Only used when sortBy is specified",
            "schema": {
              "$ref": "#/components/schemas/SortOrder"
            }
          },
          {
            "name": "includeData",
            "in": "query",
            "description": "Whether to include the sample data in the response.  Defaults to `true`",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Sample"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Samples"
        ],
        "summary": "Create sample",
        "operationId": "PostSample",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableSample"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sample"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Samples"
        ],
        "summary": "Delete sample by external id",
        "operationId": "DeleteSampleByExternalId",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "description": "The externalId of the Sample",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions/{functionId}/samples/{sampleId}": {
      "get": {
        "tags": [
          "Samples"
        ],
        "summary": "Get sample",
        "operationId": "GetSample",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sample"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Samples"
        ],
        "summary": "Delete sample",
        "operationId": "DeleteSample",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions/{functionId}/samples/{sampleId}/annotation": {
      "put": {
        "tags": [
          "Samples"
        ],
        "summary": "Update annotation",
        "operationId": "PutAnnotation",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Annotation"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/Annotation"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/Annotation"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Annotation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Annotation"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Annotation"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Samples"
        ],
        "summary": "Delete annotation",
        "operationId": "DeleteAnnotation",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions/{functionId}/samples/{sampleId}/sample-sets": {
      "post": {
        "tags": [
          "Samples"
        ],
        "summary": "Create sample set to sample",
        "operationId": "PostSampleSetToSample",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SampleSetRelationship"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SampleSetRelationship"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SampleSetRelationship"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SampleSetRelationship"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SampleSetRelationship"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SampleSetRelationship"
                }
              }
            }
          }
        }
      }
    },
    "/v1/functions/{functionId}/samples/{sampleId}/sample-sets/{sampleSetId}": {
      "delete": {
        "tags": [
          "Samples"
        ],
        "summary": "Delete sample set from sample",
        "operationId": "DeleteSampleSetFromSample",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleSetId",
            "in": "path",
            "description": "The sample set to delete",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions": {
      "get": {
        "tags": [
          "V1Functions"
        ],
        "summary": "List",
        "operationId": "List",
        "parameters": [
          {
            "name": "startIndex",
            "in": "query",
            "description": "The zero-based index of the first result to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "The number of results to return",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Function"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Function"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Function"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "V1Functions"
        ],
        "summary": "Create function",
        "operationId": "PostFunction",
        "parameters": [
          {
            "name": "waitUntilReady",
            "in": "query",
            "description": "If true, the request will wait until the function is ready before returning",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableFunction"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableFunction"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WritableFunction"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              }
            }
          }
        }
      }
    },
    "/v1/functions/{functionId}": {
      "get": {
        "tags": [
          "V1Functions"
        ],
        "summary": "Get function",
        "operationId": "GetFunction",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "V1Functions"
        ],
        "summary": "Update function",
        "operationId": "PutFunction",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableFunction"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WritableFunction"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WritableFunction"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Function"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "V1Functions"
        ],
        "summary": "Delete function",
        "operationId": "DeleteFunction",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/v1/functions/{functionId}/summary": {
      "get": {
        "tags": [
          "V1FunctionSummaries"
        ],
        "summary": "Get function summary",
        "operationId": "GetFunctionSummary",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionSummary"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionSummary"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionSummary"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search-functions/{functionId}/invoke": {
      "post": {
        "tags": [
          "V1Search"
        ],
        "summary": "Execute Invoke",
        "operationId": "Invoke",
        "parameters": [
          {
            "name": "functionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sampleCount",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeData",
            "in": "query",
            "description": "Whether to include the sample data in the response. Defaults to `true`",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchInvokeInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoke succeeded",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SearchSample"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SearchSample"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SearchSample"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Annotation": {
        "type": "object",
        "properties": {
          "labelId": {
            "type": "string",
            "nullable": true
          },
          "labelName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CaptureReason": {
        "enum": [
          "Random",
          "Uncertain",
          "RareClass",
          "LowAccuracyClass",
          "CaptureAll"
        ],
        "type": "string"
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Field": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/FieldType"
          },
          "id": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FieldType": {
        "enum": [
          "Text",
          "Number",
          "Image"
        ],
        "type": "string"
      },
      "Function": {
        "type": "object",
        "properties": {
          "projectId": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "input": {
            "$ref": "#/components/schemas/FunctionInputModality"
          },
          "output": {
            "$ref": "#/components/schemas/FunctionOutputModality"
          },
          "id": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FunctionInputModality": {
        "enum": [
          "Text",
          "Image",
          "Tabular"
        ],
        "type": "string"
      },
      "FunctionOutput": {
        "type": "object",
        "properties": {
          "labelName": {
            "type": "string",
            "nullable": true
          },
          "labelId": {
            "type": "string",
            "nullable": true
          },
          "labelMetadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "nullable": true
          },
          "confidence": {
            "type": "number",
            "format": "double"
          },
          "decisionThreshold": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "labelConfidences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LabelConfidence"
            },
            "nullable": true
          },
          "externalId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "FunctionOutputModality": {
        "enum": [
          "Classification",
          "Detection",
          "Search",
          "Ocr",
          "Localization",
          "Tags",
          "BoxDetect"
        ],
        "type": "string"
      },
      "FunctionSummary": {
        "type": "object",
        "properties": {
          "sampleCount": {
            "type": "integer",
            "format": "int32"
          },
          "annotatedSampleCount": {
            "type": "integer",
            "format": "int32"
          },
          "annotatedSampleCountByLabelId": {
            "$ref": "#/components/schemas/LabelCountDictionary"
          }
        },
        "additionalProperties": false
      },
      "IFunctionInput": {
        "type": "object",
        "properties": {
          "size": {
            "type": "integer",
            "format": "int32",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "IStreamObject": {
        "type": "object",
        "properties": {
          "typeName": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "typeVersion": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "cursor": {
            "type": "string",
            "nullable": true,
            "readOnly": true
          },
          "object": {
            "nullable": true,
            "readOnly": true
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "InvokeInput": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/IFunctionInput"
          },
          "externalId": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Label": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "nullable": true
          },
          "id": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LabelConfidence": {
        "type": "object",
        "properties": {
          "labelId": {
            "type": "string",
            "nullable": true
          },
          "labelName": {
            "type": "string",
            "nullable": true
          },
          "labelMetadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "nullable": true
          },
          "confidence": {
            "type": "number",
            "format": "double"
          },
          "decisionThreshold": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LabelCountDictionary": {
        "type": "object",
        "additionalProperties": false
      },
      "Prediction": {
        "type": "object",
        "properties": {
          "labelId": {
            "type": "string",
            "nullable": true
          },
          "confidence": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false
      },
      "Sample": {
        "type": "object",
        "properties": {
          "annotation": {
            "$ref": "#/components/schemas/Annotation"
          },
          "data": {
            "$ref": "#/components/schemas/IFunctionInput"
          },
          "externalId": {
            "type": "string",
            "nullable": true
          },
          "sampleSets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SampleSetRelationship"
            },
            "nullable": true
          },
          "id": {
            "type": "string",
            "nullable": true
          },
          "prediction": {
            "$ref": "#/components/schemas/Prediction"
          }
        },
        "additionalProperties": false
      },
      "SampleOrigin": {
        "enum": [
          "Unspecified",
          "InvokeCapture"
        ],
        "type": "string"
      },
      "SampleSetRelationship": {
        "type": "object",
        "properties": {
          "sampleSetId": {
            "type": "string",
            "nullable": true
          },
          "weight": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SampleSortBy": {
        "enum": [
          "Default",
          "Annotation",
          "Creation",
          "Confidence",
          "Agreement"
        ],
        "type": "string"
      },
      "SearchInvokeInput": {
        "type": "object",
        "properties": {
          "sampleId": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "$ref": "#/components/schemas/IFunctionInput"
          }
        },
        "additionalProperties": false
      },
      "SearchSample": {
        "type": "object",
        "properties": {
          "sampleId": {
            "type": "string",
            "nullable": true
          },
          "distance": {
            "type": "number",
            "format": "double"
          },
          "externalId": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "$ref": "#/components/schemas/IFunctionInput"
          }
        },
        "additionalProperties": false
      },
      "SortOrder": {
        "enum": [
          "Ascending",
          "Descending"
        ],
        "type": "string"
      },
      "WritableField": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/FieldType"
          }
        },
        "additionalProperties": false
      },
      "WritableFunction": {
        "type": "object",
        "properties": {
          "projectId": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "input": {
            "$ref": "#/components/schemas/FunctionInputModality"
          },
          "output": {
            "$ref": "#/components/schemas/FunctionOutputModality"
          }
        },
        "additionalProperties": false
      },
      "WritableLabel": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "WritableSample": {
        "type": "object",
        "properties": {
          "annotation": {
            "$ref": "#/components/schemas/Annotation"
          },
          "data": {
            "$ref": "#/components/schemas/IFunctionInput"
          },
          "externalId": {
            "type": "string",
            "nullable": true
          },
          "sampleSets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SampleSetRelationship"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    }
  }
}
