Skip to main content
In this section, you go through the steps to run an analysis. You set up the request for the following example where you analyze an experiment with two metrics: a crash metric used as a guardrail that you analyze sequentially, and a consumption metric that you analyze once. To go through this tutorial you need to first create an analysis plan.

Run the Analysis

To run an analysis, send a POST request to the analysis endpoint with both the analysis plan and the data:
curl -X POST "https://api.confidence.dev/v1/analysis:run" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "plan": { ... },
    "data": { ... }
  }'

Create the Analysis Data

When you’ve set up the analysis plan, you only have to add the data for analysis. The format must match what you specified in the analysis plan. For your crash metric, you have two days of data. The data for your hypothesis looks like:
{
  "id": "crashes",
  "segments": [
    {
      "dimensions": {},
      "groups": [
        {
          "group": "control",
          "data": {
            "gstZTest": {
              "summary": {
                "data": [
                  {
                    "timeLabel": "2020-01-01",
                    "value": {
                      "mean": 2,
                      "variance": 2.282828,
                      "count": 100
                    }
                  },
                  {
                    "timeLabel": "2020-01-02",
                    "value": {
                      "mean": 1.99,
                      "variance": 2.291357,
                      "count": 200
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "group": "treatment",
          "data": {
            "gstZTest": {
              "summary": {
                "data": [
                  {
                    "timeLabel": "2020-01-01",
                    "value": {
                      "mean": 2.95,
                      "variance": 2.45202,
                      "count": 100
                    }
                  },
                  {
                    "timeLabel": "2020-01-02",
                    "value": {
                      "mean": 2.97,
                      "variance": 2.702613,
                      "count": 200
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  ]
}
Your consumption data is for the whole period, and looks like:
{
  "id": "consumption",
  "segments": [
    {
      "dimensions": {},
      "groups": [
        {
          "group": "control",
          "data": {
            "zTest": {
              "summary": {
                "mean": 0.25,
                "variance": 0.1893939,
                "count": 100
              }
            }
          }
        },
        {
          "group": "treatment",
          "data": {
            "zTest": {
              "summary": {
                "mean": 0.3133333,
                "variance": 0.2165996,
                "count": 150
              }
            }
          }
        }
      ]
    }
  ]
}
This completes the data needed for your analysis. See the API reference for full request and response examples.