def remove_state(api, entity_id):
    try:
        req = api(METHOD_DELETE, URL_API_STATES_ENTITY.format(entity_id))

        if req.status_code in (200, 404):
            return True

        _LOGGER.error("Error removing state: %d - %s",
                      req.status_code, req.text)
        return False
    except HomeAssistantError:
        _LOGGER.exception("Error removing state")

        return False
Assumes that the document already exists and creates attachment to it.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/remote.py/remove_state--crossover with--dataset/ETHPy150Open ooici/pyon/pyon/datastore/couchbase/base_store.py/CouchbaseDataStore.create_attachment