I'm pretty new to the Salesforce REST API, and where do I find documentation or a resource on how to create a case in Salesforce using their API?

  • Do you want to create a REST API Web Service that will create the case or you want to use the TOOLING API in order to create a case directly in Salesforce? Aug 12, 2014 at 4:30
  • @Bachovski I want to create a case via their REST API. Aug 12, 2014 at 4:45
  • Apologies I meant the salesforce REST API not tooling :) @AtulRajguru9 has already provided a nice answer with some examples that you'll be able to work out from. Aug 12, 2014 at 4:57
  • gotcha. Sorry but off topic I notice in the document a instance_name what does it mean? I saw this in the documentation curl instance_name.salesforce.com/services/data/v20.0 -H 'Authorization: Bearer access_token' Aug 12, 2014 at 5:06
  • Instance name is the server name or the subdomain of your salesforce org (when you log in, in the URL you see ap1., eu0., cs4. etc.). Aug 12, 2014 at 5:16

2 Answers 2


Here is sample code for you:



Here is PHP code for your reference:

function create_account($name, $instance_url, $access_token) {
$url = "$instance_url/services/data/v20.0/sobjects/Account/";

$content = json_encode(array("Name" => $name));

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
        array("Authorization: OAuth $access_token",
            "Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 201 ) {
    die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));

echo "HTTP status $status creating account<br/><br/>";


$response = json_decode($json_response, true);

$id = $response["id"];

echo "New record id $id<br/><br/>";

return $id;

See the section called "Create A Record" in the REST API docs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.