# Contract Query

{% hint style="warning" %}
To use EverReal playground is required to provide the Bearer token, read more in Master Data page
{% endhint %}

To understand what is necessary and how to use graphql, in Master Data page we explain what is necessary to do

{% content-ref url="../../how-to-guide/everreal-data-import-process/master-data" %}
[master-data](https://api-docs.everreal.co/how-to-guide/everreal-data-import-process/master-data)
{% endcontent-ref %}

```graphql
type Query {
  contracts(input: ContractsFilterListPaging): [Contract]
}

type ContractTerms {
  rent: Float
  deposit: Float
  heatingCosts: Float
  utilityCosts: Float
  totalMonthlyRent: Float
  contractEndDate: Date
  contractStartDate: Date
}

type ContractData {
  terms: ContractTerms
}

type Contract {
  id: String
  startDate: Date
  endDate: Date
  contractFlowType: CONTRACT_FLOW_TYPE
  status: String
  candidate: Candidate
  units: [Unit]
  tenants: [Tenant]
  tenantFullNames: String
  versions: [JSON]
  contractData: ContractData
  contractDataString: String
  createdAt: DateTime
  updatedAt: DateTime
}

input ListContractFilter {
  id: String
  companyId: String
  propertyGroupId: String
  propertyId: String
  status: String
  from: Date
  to: Date
}

input ContractsFilterListPaging {
  filter: ListContractFilter
  paging: GraphPaging
  sort: GraphSorting
}

enum CONTRACT_FLOW_TYPE {
  VIRTUAL
  OFFLINE
  DOWNLOAD_UPLOAD
  ELECTRONIC_SIGNATURE_V2
  ELECTRONIC_SIGNATURE_QES
}
```

{% tabs %}
{% tab title="GraphQL" %}

```graphql
  query contracts($companyId: String, $propertyId: String, $status: String) {
    contracts(
      input: {
        paging: { take: 100, skip: 0 }
        filter: { companyId: $companyId, propertyId: $propertyId, status: $status }
      }
    ) {
      id
      contractDataString
        startDate
        endDate
        status
        unit {
            id
        }
        candidate {
            id
        }
        versions
        contractData {
            terms {
                rent
                deposit
                heatingCosts
                utilityCosts
                totalMonthlyRent
            }
        }
        contractDataString
        createdAt
    }
  }
```

{% endtab %}

{% tab title="CURL" %}

```bash
curl --location --request POST 'https://acme.everreal.co/api/reporting/graphql' \
--header 'Authorization: Bearer ....' \
--header 'Content-Type: application/json' \
--header 'Cookie: accept-language=en-US' \
--data-raw '{"query":"  query contracts($companyId: String, $propertyId: String, $status: String) {\n    contracts(\n      input: {\n        paging: { take: 100, skip: 0 }\n        filter: { companyId: $companyId, propertyId: $propertyId, status: $status }\n      }\n    ) {\n      id\n      contractDataString\n        startDate\n        endDate\n        status\n        unit {\n            id\n        }\n        candidate {\n            id\n        }\n        versions\n        contractData {\n            terms {\n                rent\n                deposit\n                heatingCosts\n                utilityCosts\n                totalMonthlyRent\n            }\n        }\n        contractDataString\n        createdAt\n    }\n  }","variables":{"status":"CONTRACT_TERMINATED"}}'
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer ...");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "accept-language=en-US");

var graphql = JSON.stringify({
  query: "  query contracts($companyId: String, $propertyId: String, $status: String) {\n    contracts(\n      input: {\n        paging: { take: 100, skip: 0 }\n        filter: { companyId: $companyId, propertyId: $propertyId, status: $status }\n      }\n    ) {\n      id\n      contractDataString\n        startDate\n        endDate\n        status\n        unit {\n            id\n        }\n        candidate {\n            id\n        }\n        versions\n        contractData {\n            terms {\n                rent\n                deposit\n                heatingCosts\n                utilityCosts\n                totalMonthlyRent\n            }\n        }\n        contractDataString\n        createdAt\n    }\n  }",
  variables: {"status":"CONTRACT_TERMINATED"}
})
var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: graphql,
  redirect: 'follow'
};

fetch("https://acme.everreal.co/api/reporting/graphql", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));// Some code
```

{% endtab %}
{% endtabs %}
