Fair Value of Financial Instruments - Fair Values of Financial Instruments Measured on a Recurring Basis (Details) - USD ($) $ in Thousands | Dec. 31, 2019 | Dec. 31, 2018 |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | $ 649,666 | $ 122,509 |
Marketable securities | 1,063,679 | 505,304 |
Corporate bonds | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 450,433 | 204,170 |
Corporate bonds | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 450,433 | 204,170 |
Corporate bonds | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Corporate bonds | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 450,433 | 204,170 |
Corporate bonds | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
U.S. treasury securities | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 201,640 | 35,921 |
U.S. treasury securities | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 201,640 | 35,921 |
U.S. treasury securities | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 201,640 | 35,921 |
U.S. treasury securities | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
U.S. treasury securities | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Asset-backed securities | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 114,599 | 106,658 |
Asset-backed securities | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 114,599 | 106,658 |
Asset-backed securities | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Asset-backed securities | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 114,599 | 106,658 |
Asset-backed securities | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Certificates of deposit | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 100,679 | 68,359 |
Certificates of deposit | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 100,679 | 68,359 |
Prepaid expenses and other current assets | 2,738 | 1,057 |
Restricted cash | 25,339 | 11,724 |
Certificates of deposit | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Prepaid expenses and other current assets | 0 | 0 |
Restricted cash | 0 | 0 |
Certificates of deposit | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 100,679 | 68,359 |
Prepaid expenses and other current assets | 2,738 | 1,057 |
Restricted cash | 25,339 | 11,724 |
Certificates of deposit | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Prepaid expenses and other current assets | 0 | 0 |
Restricted cash | 0 | 0 |
Commercial paper | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 196,328 | 90,196 |
Commercial paper | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 196,328 | 90,196 |
Commercial paper | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Commercial paper | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 196,328 | 90,196 |
Commercial paper | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Marketable securities | 0 | 0 |
Redeemable convertible preferred stock warrants | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Other liabilities | | 4,934 |
Redeemable convertible preferred stock warrants | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Other liabilities | | 0 |
Redeemable convertible preferred stock warrants | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Other liabilities | | 0 |
Redeemable convertible preferred stock warrants | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Other liabilities | | 4,934 |
Money market funds | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 214,413 | 785 |
Money market funds | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 214,413 | 785 |
Money market funds | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 214,413 | 785 |
Money market funds | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | 0 |
Money market funds | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | 0 |
Commercial paper | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 105,354 | 73,486 |
Commercial paper | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 105,354 | 73,486 |
Commercial paper | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | 0 |
Commercial paper | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 105,354 | 73,486 |
Commercial paper | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | $ 0 |
Corporate bonds | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 3,791 | |
Corporate bonds | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 3,791 | |
Corporate bonds | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | |
Corporate bonds | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 3,791 | |
Corporate bonds | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | |
Certificates of deposit | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 2,914 | |
Certificates of deposit | Recurring | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 2,914 | |
Certificates of deposit | Recurring | Level 1 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 0 | |
Certificates of deposit | Recurring | Level 2 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | 2,914 | |
Certificates of deposit | Recurring | Level 3 | | |
Fair Value, Assets and Liabilities Measured on Recurring and Nonrecurring Basis [Line Items] | | |
Cash equivalents | $ 0 | |