MongoDB REST API without code: webhook, database operation, answer

A MongoDB REST API without code is a ready nana800 template: a webhook takes a request with the collection, filter and data, the MongoDB block runs the operation on your database, and the result goes back to the sender. No server is needed, only a connection string to your MongoDB or Atlas database. Each API request costs three basic block runs, and your balance is topped up to $3.50 for free every month.

Build it in the builder
The MongoDB REST API template scheme in the nana800 builder

Chain of blocks

  1. 1

    Trigger

    button starts the scheme by hand for a test. The database block takes the collection and filter from the request, so put test values into its fields before a button test, or test the scheme on the API page.

  2. 2

    Trigger · Webhook (trigger)

    webhook is the address of your API. It takes JSON with the fields collection, filter (always send it, at least {}) and data (the data to write).

  3. 3

    Action · MongoDB operation

    Mongodb Database external operation runs the operation on your database. The template uses FIND_ONE, which finds one record, takes the collection and filter from the request, and you add the connection string.

  4. 4

    Action · Webhook response

    webhook response answers the sender with code 200 and JSON with a success field and the operation result in the data field.

What it is good for

  • Serve MongoDB data to a website or mobile app: a product, an order, a client profile
  • Take leads and orders from a website and save them to a collection with CREATE_ONE
  • Change an order status on a request from a CRM or a payment service with the $set operator
  • Build an app prototype with no server of your own: each API address is a separate webhook with its own operation
  • Give no-code services access to the database: any service that can send requests reads and writes records

How to set it up

  1. 1

    Open the template

    In the builder open Templates, find Simple REST API with MongoDB and press Use. A scheme with four connected blocks appears in the project you pick.

  2. 2

    Paste the connection string

    In the Mongodb Database external operation block replace the text in the connection string field with the address of your database, for example mongodb+srv://user:password@cluster0.xxxxx.mongodb.net/dbname. Encode special characters in the password, for example @ as %40. The database must be reachable from the internet: in Atlas allow access in Network Access.

  3. 3

    Pick the operation and collection

    The template uses FIND_ONE. For new records pick CREATE_ONE: the data field of the request goes into the data to write. For edits pick UPDATE_ONE, then data uses an operator, for example {"$set": {"status": "done"}}. It is safer to type the collection name into the block than to take it from the request.

  4. 4

    Set up the webhook

    In the webhook block set method to POST: the template has GET, but the data comes in the request body. In path enter a path such as /orders/find. For other operations add more webhooks with their own paths, each with its own MongoDB block and answer.

  5. 5

    Fix the response body

    In the webhook response block the result is inserted in quotes, but a found record is a JSON object, so the answer becomes invalid JSON. Move the body to the body json field, remove the quotes around the result insert and clear body raw. Then the sender gets the record as normal JSON.

  6. 6

    Turn the scheme on and test it

    Turn the scheme on, press the API button in the builder and on the Try it tab send JSON like {"collection": "orders", "filter": {"status": "new"}}. The request really runs on your database, and the answer contains the found record. An enabled scheme costs $0.0042 per hour.

Services in this template

  • Webhook

    Receive website leads and service events with a webhook and answer requests with no server and no code. Free balance every month, no card needed.

  • MongoDB

    Connect MongoDB or Atlas to nana800: find, create, update and delete documents from a scheme with no server of your own. Free balance every month, no card needed.

Frequently asked questions

One request costs three basic block runs: the webhook counts as one, the database operation as two, and the answer is free. 1,000 basic runs cost $1. The API only answers while the scheme is on, and an hour of an enabled scheme costs $0.0042. Your balance is topped up to $3.50 for free every month with no card, but a scheme kept on around the clock spends most of that on scheme hours.

The webhook address is public: anyone who knows it can send a request. In the template the collection and filter come from the request, so type the collection into the block and connect as a database user with rights only to the collections you need. For a private API check a secret header with a condition block or a token with validate jwt.

Eight: FIND_ONE and FIND_MANY find records, CREATE_ONE and CREATE_MANY create them, UPDATE_ONE and UPDATE_MANY update them, DELETE_ONE and DELETE_MANY delete them. One block runs one chosen operation, so give each operation its own webhook and path. FIND_MANY returns up to 1000 records per request.

The answer block of the template sends success: true in any case. Put a condition block on the success field of the MongoDB block before the answer, and on an error return code 400 or 500 with the text from error_text, which explains the cause. A failed operation is not charged.

Yes, the block accepts mongodb+srv:// strings from Atlas and plain mongodb:// strings from your own server. In Atlas allow connections from the internet in Network Access. Sign-in is by user name and password only: databases in a private network, proxies and certificate files are not supported.

You write no code, but the filter and data are JSON, as in MongoDB itself, so the template suits people who know the database. An ID in a filter is written as {"_id": {"$oid": "..."}}, a date as {"$date": "2025-01-01T00:00:00Z"}.

Build your first scheme for free

Sign-up is free and needs no card. Every month the balance is topped up to $3.50 for free, enough for about 3,500 runs of basic blocks.

Build it in the builder