Sign up ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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?

share|improve this question
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? –  Boris Bachovski Aug 12 '14 at 4:30
@Bachovski I want to create a case via their REST API. –  Peter Aug 12 '14 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. –  Boris Bachovski Aug 12 '14 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 -H 'Authorization: Bearer access_token' –  Peter Aug 12 '14 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.). –  Boris Bachovski Aug 12 '14 at 5:16

2 Answers 2

up vote 1 down vote accepted

Here is sample code for you:|StartTopic=Content%2Fquickstart_code.htm|SkinName=webhelp

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;
share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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