# Get holdout

GET https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/holdouts/{holdoutKey}

Get details about a holdout.

### Expanding the holdout response

LaunchDarkly supports the following fields for expanding the "Get holdout" response. By default, these fields are **not** included in the response.

To expand the response, append the `expand` query parameter and add a comma-separated list with any of the following fields:

- `draftIteration` includes the iteration which has not been started yet, if any, for this holdout.
- `previousIterations` includes all iterations prior to the current iteration, for this holdout. By default only the current iteration is included in the response.
- `rel-draftIteration` includes the iteration which has not been started yet, if any, for the experiments related to this holdout.
- `rel-metrics` includes metrics for experiments related to this holdout.
- `rel-previousIterations` includes all iterations prior to the current iteration, for the experiments related to this holdout.
- `rel-secondaryMetrics` includes secondary metrics for experiments related to this holdout.
- `rel-treatments` includes all treatment and parameter details for experiments related to this holdout.
- `secondaryMetrics` includes secondary metrics for this holdout. By default only the primary metric is included in the response.
- `treatments` includes all treatment and parameter details for this holdout. By default treatment data is not included in the response.

For example, `expand=draftIteration,rel-draftIteration` includes the `draftIteration` and `rel-draftIteration` fields in the response. If fields that you request with the `expand` query parameter are empty, they are not included in the response.


Reference: https://launchdarkly.com/docs/api/holdouts-beta/get-holdout

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/projects/{projectKey}/environments/{environmentKey}/holdouts/{holdoutKey}:
    get:
      operationId: get-holdout
      summary: Get holdout
      description: >
        Get details about a holdout.


        ### Expanding the holdout response


        LaunchDarkly supports the following fields for expanding the "Get
        holdout" response. By default, these fields are **not** included in the
        response.


        To expand the response, append the `expand` query parameter and add a
        comma-separated list with any of the following fields:


        - `draftIteration` includes the iteration which has not been started
        yet, if any, for this holdout.

        - `previousIterations` includes all iterations prior to the current
        iteration, for this holdout. By default only the current iteration is
        included in the response.

        - `rel-draftIteration` includes the iteration which has not been started
        yet, if any, for the experiments related to this holdout.

        - `rel-metrics` includes metrics for experiments related to this
        holdout.

        - `rel-previousIterations` includes all iterations prior to the current
        iteration, for the experiments related to this holdout.

        - `rel-secondaryMetrics` includes secondary metrics for experiments
        related to this holdout.

        - `rel-treatments` includes all treatment and parameter details for
        experiments related to this holdout.

        - `secondaryMetrics` includes secondary metrics for this holdout. By
        default only the primary metric is included in the response.

        - `treatments` includes all treatment and parameter details for this
        holdout. By default treatment data is not included in the response.


        For example, `expand=draftIteration,rel-draftIteration` includes the
        `draftIteration` and `rel-draftIteration` fields in the response. If
        fields that you request with the `expand` query parameter are empty,
        they are not included in the response.
      tags:
        - subpackage_holdoutsBeta
      parameters:
        - name: projectKey
          in: path
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: environmentKey
          in: path
          description: The environment key
          required: true
          schema:
            type: string
            format: string
        - name: holdoutKey
          in: path
          description: The holdout experiment key
          required: true
          schema:
            type: string
            format: string
        - name: expand
          in: query
          description: >-
            A comma-separated list of properties that can reveal additional
            information in the response. Supported fields are explained above.
            Holdout experiment expansion fields have no prefix. Related
            experiment expansion fields have `rel-` as a prefix.
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: HoldoutDetail response with full experiments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HoldoutDetailRep'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    HoldoutDetailRepStatus:
      type: string
      enum:
        - created
        - enabled
        - running
        - ended
      title: HoldoutDetailRepStatus
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    ExperimentMethodology:
      type: string
      enum:
        - bayesian
        - frequentist
        - export_only
      description: The results analysis approach.
      title: ExperimentMethodology
    ExperimentDataSource:
      type: string
      enum:
        - launchdarkly
        - snowflake
      description: >-
        The source of metric data in order to analyze results. Defaults to
        "launchdarkly" when not provided.
      title: ExperimentDataSource
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    IterationRepStatus:
      type: string
      enum:
        - not_started
        - running
        - stopped
      description: >-
        The status of the iteration: <code>not_started</code>,
        <code>running</code>, <code>stopped</code>
      title: IterationRepStatus
    FlagRep:
      type: object
      properties:
        targetingRule:
          type: string
          description: The targeting rule
        targetingRuleDescription:
          type: string
          description: The rule description
        targetingRuleClauses:
          type: array
          items:
            description: Any type
          description: >-
            An array of clauses used for individual targeting based on
            attributes
        flagConfigVersion:
          type: integer
          description: The flag version
        notInExperimentVariationId:
          type: string
          description: >-
            The ID of the variation to route traffic not part of the experiment
            analysis to
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - _links
      title: FlagRep
    DependentMetricOrMetricGroupRepKind:
      type: string
      enum:
        - pageview
        - click
        - custom
        - funnel
        - standard
      description: >-
        If this is a metric, then it represents the kind of event the metric
        tracks. If this is a metric group, then it represents the group type
      title: DependentMetricOrMetricGroupRepKind
    MetricInGroupRepKind:
      type: string
      enum:
        - pageview
        - click
        - custom
      description: The kind of event the metric tracks
      title: MetricInGroupRepKind
    MetricInGroupRepUnitAggregationType:
      type: string
      enum:
        - sum
        - average
      description: The type of unit aggregation to use for the metric
      title: MetricInGroupRepUnitAggregationType
    MetricInGroupRep:
      type: object
      properties:
        key:
          type: string
          description: The metric key
        _versionId:
          type: string
          description: The version ID of the metric
        name:
          type: string
          description: The metric name
        kind:
          $ref: '#/components/schemas/MetricInGroupRepKind'
          description: The kind of event the metric tracks
        isNumeric:
          type: boolean
          description: >-
            For custom metrics, whether to track numeric changes in value
            against a baseline (<code>true</code>) or to track a conversion when
            an end user takes an action (<code>false</code>).
        unitAggregationType:
          $ref: '#/components/schemas/MetricInGroupRepUnitAggregationType'
          description: The type of unit aggregation to use for the metric
        eventKey:
          type: string
          description: >-
            The event key sent with the metric. Only relevant for custom
            metrics.
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        nameInGroup:
          type: string
          description: >-
            Name of the metric when used within the associated metric group. Can
            be different from the original name of the metric. Required if and
            only if the metric group is a <code>funnel</code>.
        randomizationUnits:
          type: array
          items:
            type: string
          description: The randomization units for the metric
      required:
        - key
        - name
        - kind
        - _links
      title: MetricInGroupRep
    DependentMetricOrMetricGroupRep:
      type: object
      properties:
        key:
          type: string
          description: A unique key to reference the metric or metric group
        _versionId:
          type: string
          description: The version ID of the metric or metric group
        name:
          type: string
          description: A human-friendly name for the metric or metric group
        kind:
          $ref: '#/components/schemas/DependentMetricOrMetricGroupRepKind'
          description: >-
            If this is a metric, then it represents the kind of event the metric
            tracks. If this is a metric group, then it represents the group type
        isNumeric:
          type: boolean
          description: >-
            For custom metrics, whether to track numeric changes in value
            against a baseline (<code>true</code>) or to track a conversion when
            an end user takes an action (<code>false</code>).
        eventKey:
          type: string
          description: >-
            The event key sent with the metric. Only relevant for custom
            metrics.
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        isGroup:
          type: boolean
          description: Whether this is a metric group or a metric
        metrics:
          type: array
          items:
            $ref: '#/components/schemas/MetricInGroupRep'
          description: An ordered list of the metrics in this metric group
      required:
        - key
        - _versionId
        - name
        - kind
        - _links
        - isGroup
      title: DependentMetricOrMetricGroupRep
    MetricV2RepKind:
      type: string
      enum:
        - pageview
        - click
        - custom
      description: The kind of event the metric tracks
      title: MetricV2RepKind
    MetricV2RepUnitAggregationType:
      type: string
      enum:
        - sum
        - average
      description: The type of unit aggregation to use for the metric
      title: MetricV2RepUnitAggregationType
    MetricV2Rep:
      type: object
      properties:
        key:
          type: string
          description: The metric key
        _versionId:
          type: string
          description: The version ID of the metric
        name:
          type: string
          description: The metric name
        kind:
          $ref: '#/components/schemas/MetricV2RepKind'
          description: The kind of event the metric tracks
        isNumeric:
          type: boolean
          description: >-
            For custom metrics, whether to track numeric changes in value
            against a baseline (<code>true</code>) or to track a conversion when
            an end user takes an action (<code>false</code>).
        unitAggregationType:
          $ref: '#/components/schemas/MetricV2RepUnitAggregationType'
          description: The type of unit aggregation to use for the metric
        eventKey:
          type: string
          description: >-
            The event key sent with the metric. Only relevant for custom
            metrics.
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - key
        - name
        - kind
        - _links
      title: MetricV2Rep
    DependentMetricGroupRepWithMetricsKind:
      type: string
      enum:
        - funnel
        - standard
      description: The type of the metric group
      title: DependentMetricGroupRepWithMetricsKind
    DependentMetricGroupRepWithMetrics:
      type: object
      properties:
        key:
          type: string
          description: A unique key to reference the metric group
        name:
          type: string
          description: A human-friendly name for the metric group
        kind:
          $ref: '#/components/schemas/DependentMetricGroupRepWithMetricsKind'
          description: The type of the metric group
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        metrics:
          type: array
          items:
            $ref: '#/components/schemas/MetricInGroupRep'
          description: The metrics in the metric group
      required:
        - key
        - name
        - kind
        - _links
      title: DependentMetricGroupRepWithMetrics
    ParameterRep:
      type: object
      properties:
        variationId:
          type: string
        flagKey:
          type: string
      title: ParameterRep
    TreatmentRep:
      type: object
      properties:
        _id:
          type: string
          description: The treatment ID. This is the variation ID from the flag.
        name:
          type: string
          description: The treatment name. This is the variation name from the flag.
        allocationPercent:
          type: string
          description: >-
            The percentage of traffic allocated to this treatment during the
            iteration
        baseline:
          type: boolean
          description: >-
            Whether this treatment is the baseline to compare other treatments
            against
        parameters:
          type: array
          items:
            $ref: '#/components/schemas/ParameterRep'
          description: Details on the flag and variation used for this treatment
      required:
        - name
        - allocationPercent
      title: TreatmentRep
    LayerSnapshotRep:
      type: object
      properties:
        key:
          type: string
          description: Key of the layer the experiment was part of
        name:
          type: string
          description: Layer name at the time this experiment iteration was stopped
        reservationPercent:
          type: integer
          description: >-
            Percent of layer traffic that was reserved in the layer for this
            experiment iteration
        otherReservationPercent:
          type: integer
          description: >-
            Percent of layer traffic that was reserved for other experiments in
            the same environment, when this experiment iteration was stopped
      required:
        - key
        - name
        - reservationPercent
        - otherReservationPercent
      title: LayerSnapshotRep
    CovariateInfoRep:
      type: object
      properties:
        id:
          type: string
          description: The ID of the covariate matrix
        fileName:
          type: string
          description: The file name of the uploaded covariate matrix
        createdAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the covariate was uploaded
      required:
        - id
        - fileName
        - createdAt
      title: CovariateInfoRep
    IterationRep:
      type: object
      properties:
        _id:
          type: string
          description: The iteration ID
        hypothesis:
          type: string
          description: The expected outcome of this experiment
        status:
          $ref: '#/components/schemas/IterationRepStatus'
          description: >-
            The status of the iteration: <code>not_started</code>,
            <code>running</code>, <code>stopped</code>
        createdAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the iteration was created
        startedAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the iteration started
        endedAt:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the iteration ended
        winningTreatmentId:
          type: string
          description: The ID of the treatment chosen when the experiment stopped
        winningReason:
          type: string
          description: The reason you stopped the experiment
        canReshuffleTraffic:
          type: boolean
          description: >-
            Whether the experiment may reassign traffic to different variations
            when the experiment audience changes (true) or must keep all traffic
            assigned to its initial variation (false).
        flags:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/FlagRep'
          description: Details on the flag used in this experiment
        reallocationFrequencyMillis:
          type: integer
          description: >-
            The cadence (in milliseconds) to update the allocation. Only present
            for multi-armed bandits.
        version:
          type: integer
          description: The current version that the iteration is on
        primaryMetric:
          $ref: '#/components/schemas/DependentMetricOrMetricGroupRep'
          description: >-
            Deprecated, use <code>primarySingleMetric</code> and
            <code>primaryFunnel</code> instead. Details on the primary metric
            for this experiment.
        primarySingleMetric:
          $ref: '#/components/schemas/MetricV2Rep'
          description: Details on the primary metric for this experiment
        primaryFunnel:
          $ref: '#/components/schemas/DependentMetricGroupRepWithMetrics'
          description: Details on the primary funnel group for this experiment
        randomizationUnit:
          type: string
          description: The unit of randomization for this iteration
        attributes:
          type: array
          items:
            type: string
          description: The available attribute filters for this iteration
        treatments:
          type: array
          items:
            $ref: '#/components/schemas/TreatmentRep'
          description: Details on the variations you are testing in the experiment
        secondaryMetrics:
          type: array
          items:
            $ref: '#/components/schemas/MetricV2Rep'
          description: >-
            Deprecated, use <code>metrics</code> instead. Details on the
            secondary metrics for this experiment.
        metrics:
          type: array
          items:
            $ref: '#/components/schemas/DependentMetricOrMetricGroupRep'
          description: Details on the metrics for this experiment
        layerSnapshot:
          $ref: '#/components/schemas/LayerSnapshotRep'
          description: >-
            Snapshot of the layer state on iteration stop, if part of a layer.
            Otherwise omitted.
        covariateInfo:
          $ref: '#/components/schemas/CovariateInfoRep'
          description: Details of the covariate file for stratified sampling
      required:
        - hypothesis
        - status
        - createdAt
      title: IterationRep
    AnalysisConfigRepMultipleComparisonCorrectionMethod:
      type: string
      enum:
        - bonferroni
        - benjamini-hochberg
      description: The method for multiple comparison correction.
      title: AnalysisConfigRepMultipleComparisonCorrectionMethod
    AnalysisConfigRepMultipleComparisonCorrectionScope:
      type: string
      enum:
        - variations
        - variations-and-metrics
        - metrics
      description: The scope for multiple comparison correction.
      title: AnalysisConfigRepMultipleComparisonCorrectionScope
    AnalysisConfigRep:
      type: object
      properties:
        bayesianThreshold:
          type: string
          description: >-
            The threshold for the Probability to Beat Baseline (PBBL) and
            Probability to Be Best (PBB) comparisons for the Bayesian results
            analysis approach.  Value should be between 0-100 inclusive.
        significanceThreshold:
          type: string
          description: >-
            The significance threshold for the frequentist results analysis
            approach. Value should be between 0.0-1.0 inclusive.
        testDirection:
          type: string
          description: >-
            The test sided direction for the frequentist results analysis
            approach.
        multipleComparisonCorrectionMethod:
          $ref: >-
            #/components/schemas/AnalysisConfigRepMultipleComparisonCorrectionMethod
          description: The method for multiple comparison correction.
        multipleComparisonCorrectionScope:
          $ref: >-
            #/components/schemas/AnalysisConfigRepMultipleComparisonCorrectionScope
          description: The scope for multiple comparison correction.
        sequentialTestingEnabled:
          type: boolean
          description: Whether sequential testing is enabled for Frequentist analysis
      title: AnalysisConfigRep
    Experiment:
      type: object
      properties:
        _id:
          type: string
          description: The experiment ID
        key:
          type: string
          description: The experiment key
        name:
          type: string
          description: The experiment name
        description:
          type: string
          description: The experiment description
        _maintainerId:
          type: string
          description: The ID of the member who maintains this experiment.
        _creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the experiment was created
        environmentKey:
          type: string
        methodology:
          $ref: '#/components/schemas/ExperimentMethodology'
          description: The results analysis approach.
        dataSource:
          $ref: '#/components/schemas/ExperimentDataSource'
          description: >-
            The source of metric data in order to analyze results. Defaults to
            "launchdarkly" when not provided.
        archivedDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the experiment was archived
        tags:
          type: array
          items:
            type: string
          description: Tags for the experiment
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        holdoutId:
          type: string
          description: The holdout ID
        currentIteration:
          $ref: '#/components/schemas/IterationRep'
          description: Details on the current iteration
        type:
          type: string
          description: The experiment type
        draftIteration:
          $ref: '#/components/schemas/IterationRep'
          description: >-
            Details on the current iteration. This iteration may be already
            started, or may still be a draft.
        previousIterations:
          type: array
          items:
            $ref: '#/components/schemas/IterationRep'
          description: Details on the previous iterations for this experiment.
        analysisConfig:
          $ref: '#/components/schemas/AnalysisConfigRep'
          description: Details of the Analysis Configuration for this experiment.
      required:
        - key
        - name
        - _maintainerId
        - _creationDate
        - environmentKey
        - _links
      title: Experiment
    HoldoutDetailRep:
      type: object
      properties:
        _id:
          type: string
        status:
          $ref: '#/components/schemas/HoldoutDetailRepStatus'
        description:
          type: string
        holdoutAmount:
          type: string
          description: The percentage of traffic allocated to this holdout.
        isDirty:
          type: boolean
          description: >-
            Indicates if the holdout experiment is running and if any related
            experiments are running.
        createdAt:
          $ref: '#/components/schemas/UnixMillis'
        updatedAt:
          $ref: '#/components/schemas/UnixMillis'
        baseExperiment:
          $ref: '#/components/schemas/Experiment'
        relatedExperiments:
          type: array
          items:
            $ref: '#/components/schemas/Experiment'
      required:
        - _id
        - status
        - holdoutAmount
        - createdAt
        - updatedAt
        - baseExperiment
      title: HoldoutDetailRep
    InvalidRequestErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: InvalidRequestErrorRep
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    NotFoundErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: NotFoundErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey"

headers = {"Authorization": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey';
const options = {method: 'GET', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/holdouts/holdoutKey")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```