Skip to content

HawkFlow.ai REST API

The easiest way to use HawkFlow.ai is to use one of our prebuilt packages. You can find instructions on how to use those in our Development guide.

If a package is not available in your preferred language, or you simply would like to write you own code to use our REST API, here are the details.

API Authentication

HawkFlow.ai uses an API key to authenticate to our API. You receive an API after making an account. Your API key should be included in all API requests to the server in a header that looks like the following:

** Example HTTP header using the Hawkflow API key**

POST /v1/start HTTP/1.1
Host: api.hawkflow.ai
content-type: application/json
x-hawkflow-api-key: your-api-key-here

API data payloads

Data should be sent to the API in the body of an HTTP POST request in JSON format

API response codes

Code Status Meaning
201 created Successful use of the API
500 error Please check the response for the error details
401 unauthorized Failed to authenticate using your api key
422 incorrect data Incorrect JSON data sent to the endpoint. Please check the response for the error details

Timed API - Monitor code performance

What is the Timed API endpoint used for?

The Timed API endpoint is used to time any part of your code.
See below on how to use it. See the [concepts](../concepts/index.md) page for all the benefits and features
that you receive by using the Timed API endpoint.

There is a start endpoint to use when a process is starting, and another endpoint to use when the process is ending. 
Both endpoints take the same paramters.

** Start process endpoint url **

https://api.hawkflow.ai/v1/start

** End process endpoint url **

https://api.hawkflow.ai/v1/end

** JSON fields used in both start and end endpoint **

Parameter Type size format Required Description
process string max length 250 string, ',",% will be stripped required The Process name
meta string max length 500 string, ',",% will be stripped optional The meta details about your process
uid uuid max length 50 allowed a-z, 0-9, -_ optional Unique process identifier. If you would like to send multiple processes that run at the same time using the same values for process and meta, then you can use this parameter to identify their uniqueness
curl https://api.hawkflow.ai/v1/start \
    -X POST \
    -H "x-hawkflow-api-key: --INSERT-YOUR-API-KEY--" \
    -H "content-type: application/json" \
    -d @- <<'EOF'
    {
        "process": "Name of the process",
        "meta": "Your meta data here"
    }
EOF
curl https://api.hawkflow.ai/v1/end \
    -X POST \
    -H "x-hawkflow-api-key: --INSERT-YOUR-API-KEY--" \
    -H "content-type: application/json" \
    -d @- <<'EOF'
    {
        "process": "Name of the process",
        "meta": "Your meta data here"
    }
EOF

Metrics API - Monitor numerical values

What is the Metrics API endpoint used for?

The Metrics API endpoint is used to send HawkFlow any numerical value.
See below on how to use it. See the [concepts](../concepts/index.md#metrics) page for all the benefits and features
that you receive by using the Metrics API endpoint.

** Metrics endpoint url **

https://api.hawkflow.ai/v1/metrics

** JSON fields for the metrics endpoint **

Parameter Type size format Required Description
process string max length 250 string, ',",% will be stripped required The Process name
meta string max length 500 string, ',",% will be stripped optional The meta details about your process
items list of dict, see curl example below for more details max length 50 items dict key: string, ',",% are not allowed. Value: any numerical required You can send multiple metrics at once in a List. Each metric should be in its own dict with its name and value
curl https://api.hawkflow.ai/v1/metrics \
    -X POST \
    -H "x-hawkflow-api-key: --INSERT-YOUR-API-KEY--" \
    -H "content-type: application/json" \
    -d @- <<'EOF'
    {
        "process": "Name of the process",
        "meta": "Your meta data here",
        "items": {
            "model_accuracy": 0.85,
            "number_of_rows_inserted": 15664,
            "users": 133
        }
    }
EOF

Exception API - Monitor exceptions

What is the Exception API endpoint used for?

The Exception API endpoint is used to send HawkFlow exceptions that occur in your code.
See below on how to use it. See the [concepts](../concepts/index.md#exceptions) page for all the benefits and features
that you receive by using the Exception API endpoint.

** Exception endpoint url **

https://api.hawkflow.ai/v1/exception

** JSON fields for the exception endpoint **

Parameter Type size format Required Description
process string max length 250 string, ',",% will be stripped required The Process name
meta string max length 500 string, ',",% will be stripped optional The meta details about your process
exception string max length 15000 any string required The text of the exception
curl https://api.hawkflow.ai/v1/exception \
    -X POST \
    -H "x-hawkflow-api-key: --INSERT-YOUR-API-KEY--" \
    -H "content-type: application/json" \
    -d @- <<'EOF'
    {
        "process": "Name of the process",
        "meta": "Your meta data here",
        "exception": "Your exception text data here"
    }
EOF