## Retrieve IntegrationRuns

### cURL

```bash
curl --request GET \
  --url https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest \
  --header 'Authorization: Bearer <token>'
```

### Python

```python
import requests

url = "https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest"

headers = {"Authorization": "Bearer <token>"}

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

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "GET",\
  CURLOPT_HTTPHEADER => [\
    "Authorization: Bearer <token>"\
  ],\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

### Go

```go
package main

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

func main() {

url := "https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest"

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

req.Header.Add("Authorization", "Bearer <token>")

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

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

fmt.Println(string(body))
}
```

### Unirest (Java)

```java
HttpResponse<String> response = Unirest.get("https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest")
  .header("Authorization", "Bearer <token>")
  .asString();
```

### Ruby

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

url = URI("https://api.m3ter.com/organizations/{orgId}/integrationruns/{entityType}/latest")

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

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

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

### HTTP Response Status Codes
- 200
- 4XX
- 5XX

### Response Schema
```json
{
  "id": "<string>",
  "entityType": "<string>",
  "entityId": "<string>",
  "status": "<unknown>",
  "destination": "<string>",
  "version": 123,
  "dtCreated": "2023-11-07T05:31:56Z",
  "dtLastModified": "2023-11-07T05:31:56Z",
  "createdBy": "<string>",
  "lastModifiedBy": "<string>",
  "dtStarted": "2023-11-07T05:31:56Z",
  "dtCompleted": "2023-11-07T05:31:56Z",
  "destinationId": "<string>",
  "error": "<string>",
  "url": "<string>",
  "externalId": "<string>",
  "parentIntegrationRunId": "<string>",
  "replayedFromIntegrationRunId": "<string>"
}
```
### Error Response
```json
{
  "message": "<string>"
}
```
### Authorizations
- **Authorization**: string (header) required
  - m3ter supports machine to machine authentication using the `clientCredentials` OAuth2 flow.
  - The `authorizationCode` flow controls access for human users via the m3ter Console application.

### Path Parameters
- **orgId**: string required
  - UUID of the organization
- **entityType**: string required
  - The type of the entity (e.g. Bill).

### Query Parameters
- **ids**: string[]
  - List of ids to retrieve

### Response
- **200**: application/json
  - Return the IntegrationRuns
  - Response containing an IntegrationRun entity.

### Individual Property Details
- **id**: UUID of the entity  (required)
- **entityType**: type of entity the integration run is for (required)
- **entityId**: unique identifier (UUID) of the entity the integration run is for (required)
- **status**: any type (required)
- **destination**: the destination system (required)
- **version**: incremented version number
- **dtCreated**: creation date-time (in ISO-8601 format)
- **dtLastModified**: last modified date-time (in ISO-8601 format)
- **createdBy**: ID of user who created the item
- **lastModifiedBy**: ID of user who last modified the item
- **dtStarted**: start date-time (in ISO-8601 format)
- **dtCompleted**: completion date-time (in ISO-8601 format)
- **destinationId**: identifier of destination
- **error**: error description if any
- **url**: URL of the entity in destination system if available
- **externalId**: external ID in destination system if available
- **parentIntegrationRunId**: ID of parent integration run, null if it is a parent run
- **replayedFromIntegrationRunId**: ID of integration run this was replayed from, null if this is not a replay
