Update:
The other answer was added ~8 months after mine. I was unaware of the location header in the response at the time. That does sound like a good option for some cases. That said, based on the caveats in the answer and the comments (especially around parameterized builds), it appears that this answer still has some utility for some cases.
Original answer:
Unfortunately, they don't make this as straightforward as it could be. i.e. by, say, returning a JSON response with information like an id.
However, I believe a solid, though certainly non-trivial, workaround to that would be to leverage the cause parameter in the URL you use to trigger the build, and within that cause, add unique text that you can later parse to determine that you triggered it from your automation.
To further uniqueify the specific job, in case multiple are running around the same time, even from your automation, also include a unique ID of some type (it could simply be a sequence ID from your RDBMS or similar) inside of the cause parameter.
Then, you can use the JSON API to get information about the job you're remotely triggering. Again, it's somewhat indirect, but doable:
Hit a URL of the form:
http://<server>:<port>/job/<jobname>/lastBuild/api/json
You can add ?pretty=true
to pretty-print it within the browser for better human readability.
That will get you the JSON of the last build. It will contain the causes attribute within the actions attribute, and in there (in another nested attribute named shortDescription) you would find the cause parameter you added, if this was one of the builds you triggered.
You could parse out both the special static text, and your generated ID to see if they match. If they do, you can then get the Jenkins id out of the JSON as well (search for buildNumber, which is nested).
If that build is either not triggered by your automation at all, or was, but the ID doesn't match, you can repeat the process for the N - 1 build until you find what you're looking for.
That JSON would be of the form:
http://<server>:<port>/job/<jobname>/<buildNumber>/api/json