import { CodeBlock } from "../CodeBlock/CodeBlock"; export const HTTPManual: React.FC<{ domain: string; writeKey?: string }> = ({ domain, writeKey }) => { return (

HTTP API

You can use server to server API to send data to Jitsu. This is useful if you want to send data from your backend.

In case of using HTTP API you may need to manually ad user's IP address and User Agent to the event.

Ingest endpoint (client mode)

This endpoint can be used to send events to Jitsu from user devices or browsers:

{`${domain}/api/s/{event-type}`}

event-type could be:

The endpoint accepts POST requests with events payload in JSON format.

Ingest endpoint (server mode)

This endpoint can be used to send events to Jitsu from servers:

{`${domain}/api/s/s2s/{event-type}`}

event-type could be:

The endpoint accepts POST requests with events payload in JSON format. Pay attention to s2s part of the URL.
The presence of this part indicates that the event is sent from server-to-server. Unlike browser events, s2s events are processed differently:

Examples

Send track event:

{`curl --location '${domain}/api/s/s2s/track' \\ --header 'Content-Type: application/json' \\ --header 'X-Write-Key: ${writeKey}' \\ --data-raw '{ "type": "track", "event": "testEvent", "properties": { "testProp": "test event properties" }, "userId": "user@example.com", "anonymousId": "bKTtbVZw3yiqCJvCSJgjVeXp", "timestamp": "2023-04-12T13:29:04.690Z", "sentAt": "2023-04-12T13:29:04.690Z", "messageId": "voV6fulcZR4CTVnN89AnxFnC", "context": { "library": { "name": "jitsu-js", "version": "1.0.0" }, "ip": "127.0.0.1", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/111.0", "locale": "en-US", "screen": { "width": 2304, "height": 1296, "innerWidth": 1458, "innerHeight": 1186, "density": 2 }, "traits": { "email": "user@example.com" }, "page": { "path": "/", "referrer": "", "referring_domain": "", "host": "example.com", "search": "", "title": "Example page event", "url": "https://example.com/", "encoding": "UTF-8" }, "campaign": { "name": "example", "source": "g" } }, "receivedAt": "2023-04-12T13:29:04.690Z" }'`}
); };