In the United States you can obtain a restraining order from the judicial system. The restraining order prohibits (restrains) a person from taking actions that might harm or harass you (and, perhaps, tells the other party to stay a certain distance away). This would be issued by a judge, generally in an ongoing lawsuit such as a divorce or custody battle which become heated.
Speak with an attorney who practices in the area of your concern: a family law or divorce attorney. If you are worried about a spouse or an ex, the attorney will be able to handle the details for you. You can be much more likely to succeed, than if you go on your own, especially if the other party has a lawyer.
Gather evidence. “He said, She said” cases without enough evidence are a dime a dozen in the courts. You want more than just your accusation that he or she did something that warrants a restraining order. You can use threatening texts, recordings of harassing phone calls and pictures of shredding documents as a basis for a restraining order with great success. If you are filing an ex parte restraining order (discussed below) you will need a sworn affidavit in support.
Prepare a motion requesting the restraining order. This is the document that tells the judge what you want and why you want it. They come in two types. The standard asks for a restraining order and sets a hearing date for the parties to appear before the judge and have him or her decide. The other is an ex parte restraining order, which means that only one party is going to be there asking the judge for the order. If the judge grants an ex parte restraining order he or she is required to set a hearing within 14 days to allow the other side to explain themselves and request that the restraining order not be granted. Essentially this is a short term fix in emergencies.
Serve notice officially on the other party with the hearing date. Your attorney probably uses a process server that will do that for both of you.
Attend your hearing. Dress well (no collarless shirt for a man) and wear a belt, no sagging. Stay calm. Explain your position clearly, and present any evidence you may have gathered. Follow all of your lawyer’s advice on giving testimony, etc.
Prepare an order that reflects the judge’s ruling in formal language with the date and duration of the order.
Present it to the judge or clerk to get it signed by the judge.
Get the official order served on the other party.