writes to api