# Read and write data

After we've completed setting up the object classes and their properties , we are ready to start reading and writing data in the format we just specified. More specifically, we'll create instances of the Prescription class in the Medable cloud.

The following examples use HTTP. This is most applicable for web development. You might issue these HTTP requests using a tool like Fetch or Ajax. If you're doing iOS or Android development, we wrote SDK's that make it easier for you to interact with these endpoints.

## Create

Creating prescriptions is a simple matter of a `POST` request to the object route.

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

```
POST https://api.dev.medable.com/{{your_org_name}}/v2/c_prescriptions
```

{% endtab %}

{% tab title="Body" %}

```javascript
{
    "c_rx":"Doxycycline 100mg tab. Take one PO bid.",
    "c_dispense": 60,
    "c_refills": 3,
    "c_date":"2016-07-01",
    "c_patient":"575f58281d0c03a53ccc3ac6",
    "c_provider":"5771495a1d0c03a53ce83f1a"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "_id": "577c883c6f3035ee08357dfa",
    "access": 7,
    "c_date": "2016-07-01",
    "c_dispense": 60,
    "c_patient": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "c_provider": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    },
    "c_refills": 3,
    "c_rx": "Doxycycline 100mg tab. Take one PO bid.",
    "created": "2016-07-06T04:25:32.558Z",
    "creator": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "favorite": false,
    "object": "c_prescription",
    "owner": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "shared": false
}
```

{% endtab %}
{% endtabs %}

Following this process using the WAPI would look like this:

{% hint style="info" %}
Change the account IDs fo&#x72;*`c_patient` and `c_provider`* to match those in your org.
{% endhint %}

![](/files/-Mj66VBo4JmXlNAtlbjd)

## Get Many

To get that prescription we just created back, we can simply do a `GET` request.

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

```
GET https://api.dev.medable.com/{{your_org_name}}/v2/c_prescriptions
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "data": [
        {
            "_id": "577c883c6f3035ee08357dfa",
            "access": 7,
            "c_date": "2016-07-01",
            "c_dispense": 60,
            "c_patient": {
                "_id": "575f58281d0c03a53ccc3ac6",
                "object": "account",
                "path": "/accounts/575f58281d0c03a53ccc3ac6"
            },
            "c_provider": {
                "_id": "5771495a1d0c03a53ce83f1a",
                "object": "account",
                "path": "/accounts/5771495a1d0c03a53ce83f1a"
            },
            "c_refills": 3,
            "c_rx": "Doxycycline 100mg tab. Take one PO bid.",
            "created": "2016-07-06T04:25:32.558Z",
            "creator": {
                "_id": "575f58281d0c03a53ccc3ac6",
                "object": "account",
                "path": "/accounts/575f58281d0c03a53ccc3ac6"
            },
            "favorite": false,
            "object": "c_prescription",
            "owner": {
                "_id": "575f58281d0c03a53ccc3ac6",
                "object": "account",
                "path": "/accounts/575f58281d0c03a53ccc3ac6"
            },
            "shared": false
        }
    ],
    "hasMore": false,
    "object": "list"
}
```

{% endtab %}
{% endtabs %}

## Get One

Or to get a specific Prescription we can do the following `GET` request.

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

```
GET https://api.dev.medable.com/{{your_org_name}}/v2/c_prescriptions/{{object_id}}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "_id": "577c883c6f3035ee08357dfa",
    "access": 7,
    "c_date": "2016-07-01",
    "c_dispense": 60,
    "c_patient": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "c_provider": {
        "_id": "5771495a1d0c03a53ce83f1a",
        "object": "account",
        "path": "/accounts/5771495a1d0c03a53ce83f1a"
    },
    "c_refills": 3,
    "c_rx": "Doxycycline 100mg tab. Take one PO bid.",
    "created": "2016-07-06T04:25:32.558Z",
    "creator": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "favorite": false,
    "object": "c_prescription",
    "owner": {
        "_id": "575f58281d0c03a53ccc3ac6",
        "object": "account",
        "path": "/accounts/575f58281d0c03a53ccc3ac6"
    },
    "shared": false
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
For more on CRUD operations on objects, see [Cortex API Reference](/cortex-api/cortex-api.md).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.medable.com/getting-started/cortex-user-guide/write-and-read-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
