Skip to content

Quickstart: your first trip

Get sandbox keys, answer a quote and a booking, send your first signed event and see it in the portal.

Note: You need portal access. We send it when your application is approved. About 15 minutes once your server can answer HTTPS.
  1. Step 1: Sign in and get sandbox keys

    Open the partner portal and sign in with your email and the 6-digit code we email you. In Setup, under Keys, issue sandbox keys. You get an API key (prk_test_...) and a webhook secret, shown once.

    Shell
    export PR_API_KEY=prk_test_...   # you send it to us as Bearer
    export PR_SECRET=...              # the webhook secret: both sides sign with it
  2. Step 2: Connect your sandbox

    In Connect, save your Sandbox API URL, your Webhook URL and Your API key for us (we send it to you as Bearer). Only an owner can change these.

    Tip: No server yet? The sample server runs a full trip in one file.
  3. Step 3: Answer a quote and a booking

    Build POST /quotes and POST /trips (details in Quotes and booking). Then press Run tests in Test your API: we quote, book twice, get and cancel, and send a wrong signature and an old timestamp you must refuse.

    # Call your own sandbox the way PerfectRide does (signed with your secret).
    # The signed path is the path after your base URL: /quotes.
    TS=$(date +%s)
    BODY='{"pickup":{"lat":4.8156,"lng":7.0345,"address":"Hotel Presidential, Aba Road, Port Harcourt"},"dropoff":{"lat":4.8242,"lng":6.9969,"address":"Genesis Centre, GRA Phase 2, Port Harcourt"},"ride_class":"standard","passengers":1,"payment_method":"perfectride"}'
    SIG=$(printf '%s' "$TS.POST./quotes.$BODY" | openssl dgst -sha256 -hmac "$PR_SECRET" | sed 's/^.*= //')
    
    curl "$YOUR_BASE_URL/quotes" \
      -H "Authorization: Bearer $KEY_YOU_GAVE_US" \
      -H "Content-Type: application/json" \
      -H "X-PR-Timestamp: $TS" \
      -H "X-PR-Signature: sha256=$SIG" \
      --data-raw "$BODY"
  4. Step 4: Send trip.driver_assigned

    In Certification, press start. We book test trips in your sandbox and list each one with its pr_trip_id and PIN. Copy the id of the first trip and send trip.driver_assigned for it.

    TS=$(date +%s)
    NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
    PR_TRIP_ID=pr_xxxx   # the test trip from the portal
    BODY='{"event":"trip.driver_assigned","event_id":"ev_0001","partner_trip_id":"t_9931","pr_trip_id":"'"$PR_TRIP_ID"'","occurred_at":"'"$NOW"'","driver":{"id":"d_771","name":"Musa A.","phone":"+2348090001122"},"vehicle":{"make":"Toyota","model":"Corolla","color":"Black","plate":"PHC-123-AB"},"eta_seconds":240}'
    SIG=$(printf '%s' "$TS.POST./events.$BODY" | openssl dgst -sha256 -hmac "$PR_SECRET" | sed 's/^.*= //')
    
    curl https://www.perfectride.io/api/partner/v1/events \
      -H "Authorization: Bearer $PR_API_KEY" \
      -H "Content-Type: application/json" \
      -H "X-PR-Timestamp: $TS" \
      -H "X-PR-Signature: sha256=$SIG" \
      --data-raw "$BODY"
    Response 200
    { "ok": true, "result": "applied", "trip_status": "driver_assigned" }
  5. Step 5: See it in the portal

    Open Event log and press Refresh. Your event shows as accepted, or refused with the error code and why. Then play the rest of the test trips to pass certification.

Warning: A 401 bad_signature almost always means the signed body is not the exact body sent. Sign the string you send, byte for byte.

View this page as Markdown · hello@perfectride.io